Streaks Service

Mushu Streaks tracks daily activity streaks for your users. Record activities, maintain streak counts, and query activity history - all timezone-aware.

Key Features

  • Timezone-aware - Streaks calculated in user's local time
  • Grace periods - Configure forgiveness for missed days
  • Multiple activity types - Track different actions independently
  • History queries - Query activity by date range

Endpoints

MethodEndpointDescription
POST/apps/{app_id}/streaks/{user_id}/recordRecord an activity
GET/apps/{app_id}/streaks/{user_id}Get user's streaks
GET/apps/{app_id}/streaks/{user_id}/historyGet activity history

Recording Activity

curl -X POST https://streaks.mushucorp.com/apps/app_123/streaks/user_456/record \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "activity_type": "workout",
    "timezone": "America/Los_Angeles"
  }'

Response:

{
  "activity_id": "act_abc123",
  "current_streak": 5,
  "longest_streak": 12,
  "total_count": 47,
  "streak_extended": true,
  "streak_started": false
}

Getting Streaks

curl https://streaks.mushucorp.com/apps/app_123/streaks/user_456 \
  -H "X-API-Key: your-api-key"

Response:

[
  {
    "user_id": "user_456",
    "activity_type": "workout",
    "current_streak": 5,
    "longest_streak": 12,
    "total_count": 47,
    "last_activity_date": "2026-01-25",
    "last_activity_at": "2026-01-25T14:30:00Z"
  }
]

Activity History

Query with date range and activity type filters:

curl "https://streaks.mushucorp.com/apps/app_123/streaks/user_456/history?\
activity_type=workout&start_date=2026-01-01&end_date=2026-01-31" \
  -H "X-API-Key: your-api-key"

Configuration

Configure streaks per-app via the /apps/{app_id}/config endpoint:

  • grace_period_days - Days a user can miss before streak resets (default: 0)
  • activity_types - Restrict to specific activity types (empty = allow any)

How Streaks Work

  1. Activity timestamp is converted to user's timezone
  2. Date is extracted (YYYY-MM-DD in user's timezone)
  3. If same date as last activity: no streak change
  4. If consecutive day: streak incremented
  5. If gap > grace period: streak resets to 1

API Reference

Full OpenAPI documentation: streaks.mushucorp.com/docs