Skip to main content

Log Activity

curl -X POST https://api.inspir.uk/api/streaks/activity \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "activityType": "quiz_completed",
    "timeMinutes": 15
  }'
Log a study activity for the current day. Automatically updates streak information.

Request

activityType
string
required
Type of study activity (e.g., quiz_completed, study_guide_created, flashcard_session)
timeMinutes
number
default:"0"
Duration of activity in minutes

Response

activity
object
streak
object
{
  "activity": {
    "user_id": "user123",
    "activity_date": "2024-01-15",
    "activity_type": "quiz_completed",
    "activity_count": 1,
    "total_time_minutes": 15
  },
  "streak": {
    "current_streak": 7,
    "longest_streak": 14,
    "total_study_days": 42
  }
}

Errors

error
string
Error message
{
  "error": "Activity type is required"
}

Get Current Streak

curl https://api.inspir.uk/api/streaks/current \
  -H "Authorization: Bearer YOUR_TOKEN"
Get the current user’s streak information.

Response

current_streak
number
Current consecutive days with activity
longest_streak
number
Longest streak ever achieved
total_study_days
number
Total number of days with study activity
last_activity_date
string
Date of last activity (YYYY-MM-DD format)
streak_freeze_count
number
Number of streak freezes available
{
  "current_streak": 7,
  "longest_streak": 14,
  "total_study_days": 42,
  "last_activity_date": "2024-01-15",
  "streak_freeze_count": 2
}

Get Activity History

curl https://api.inspir.uk/api/streaks/history?days=30 \
  -H "Authorization: Bearer YOUR_TOKEN"
Get study activity history for the specified time period.

Query Parameters

days
number
default:"30"
Number of days to retrieve (going back from today)

Response

activities
array
Array of activity records sorted by date (descending)
groupedByDate
object
Activities grouped by date for easier consumption
totalDays
number
Number of unique days with activity in the period
{
  "activities": [
    {
      "user_id": "user123",
      "activity_date": "2024-01-15",
      "activity_type": "quiz_completed",
      "activity_count": 3,
      "total_time_minutes": 45
    },
    {
      "user_id": "user123",
      "activity_date": "2024-01-15",
      "activity_type": "study_guide_created",
      "activity_count": 1,
      "total_time_minutes": 20
    },
    {
      "user_id": "user123",
      "activity_date": "2024-01-14",
      "activity_type": "quiz_completed",
      "activity_count": 2,
      "total_time_minutes": 30
    }
  ],
  "groupedByDate": {
    "2024-01-15": [
      {
        "activity_type": "quiz_completed",
        "activity_count": 3,
        "total_time_minutes": 45
      },
      {
        "activity_type": "study_guide_created",
        "activity_count": 1,
        "total_time_minutes": 20
      }
    ],
    "2024-01-14": [
      {
        "activity_type": "quiz_completed",
        "activity_count": 2,
        "total_time_minutes": 30
      }
    ]
  },
  "totalDays": 2
}

Get Activity Stats

curl https://api.inspir.uk/api/streaks/stats?days=30 \
  -H "Authorization: Bearer YOUR_TOKEN"
Get aggregated statistics by activity type for the specified time period.

Query Parameters

days
number
default:"30"
Number of days to analyze (going back from today)

Response

Returns an object where keys are activity types and values are aggregated statistics.
[activityType]
object
{
  "quiz_completed": {
    "count": 15,
    "totalTimeMinutes": 225
  },
  "study_guide_created": {
    "count": 3,
    "totalTimeMinutes": 60
  },
  "flashcard_session": {
    "count": 8,
    "totalTimeMinutes": 120
  }
}

Build docs developers (and LLMs) love