Private personal API built for Cloudflare Workers + D1.
Interactive API documentation is available at https://api.anuragd.me/docs (requires Bearer token authentication).
The Swagger UI interface provides:
- Complete API reference with all 149+ endpoints
- Interactive "Try it out" functionality to test endpoints directly
- Request/response schemas and validation rules
- Authentication testing with Bearer token
To use the interactive documentation:
- Navigate to
/docsin your browser (no authentication required to view) - Browse all endpoints and their documentation
- When you want to test endpoints, click the "Authorize" button and enter your Bearer token
- Explore and test endpoints with live API calls
The OpenAPI 3.0 specification is also available at /openapi.json for programmatic access.
All /v1/* routes require Authorization: Bearer <API_TOKEN>.
List endpoints support ?limit&offset&search&sort&tags&start&end where applicable.
GET /openapi.json(no auth) - OpenAPI 3.0 specificationGET /docs(no auth) - Interactive API documentation (Swagger UI)GET /health(auth required)GET /v1/export
GET /v1/profilePUT /v1/profileGET /v1/nowPUT /v1/nowGET /v1/settingsPUT /v1/settings
GET /v1/projectsGET /v1/projects/{id}POST /v1/projectsPUT /v1/projects/{id}PATCH /v1/projects/{id}DELETE /v1/projects/{id}GET /v1/notesGET /v1/notes/{id}POST /v1/notesPUT /v1/notes/{id}PATCH /v1/notes/{id}DELETE /v1/notes/{id}GET /v1/eventsGET /v1/events/{id}POST /v1/eventsPUT /v1/events/{id}PATCH /v1/events/{id}DELETE /v1/events/{id}GET /v1/postsGET /v1/posts/{id}POST /v1/postsPUT /v1/posts/{id}PATCH /v1/posts/{id}DELETE /v1/posts/{id}GET /v1/photosGET /v1/photos/{id}POST /v1/photosPUT /v1/photos/{id}PATCH /v1/photos/{id}DELETE /v1/photos/{id}POST /v1/photos/upload
GET /v1/custom/exercisesPOST /v1/custom/exercisesGET /v1/custom/exercises/{id}PUT /v1/custom/exercises/{id}DELETE /v1/custom/exercises/{id}GET /v1/custom/workout-templatesPOST /v1/custom/workout-templatesGET /v1/custom/workout-templates/{id}PUT /v1/custom/workout-templates/{id}DELETE /v1/custom/workout-templates/{id}GET /v1/custom/workout-schedulesPOST /v1/custom/workout-schedulesGET /v1/custom/workout-schedules/{id}PUT /v1/custom/workout-schedules/{id}DELETE /v1/custom/workout-schedules/{id}GET /v1/custom/workout-sessionsPOST /v1/custom/workout-sessionsGET /v1/custom/workout-sessions/{id}PUT /v1/custom/workout-sessions/{id}DELETE /v1/custom/workout-sessions/{id}GET /v1/custom/workout-sessions/{id}/setsPOST /v1/custom/workout-sessions/{id}/setsPOST /v1/custom/workout-sessions/{id}/sets/bulkPATCH /v1/custom/workout-sessions/{id}/sets/{set_id}DELETE /v1/custom/workout-sessions/{id}/sets/{set_id}GET /v1/custom/workout-setsGET /v1/logsPOST /v1/logsGET /v1/logs/{id}PUT /v1/logs/{id}DELETE /v1/logs/{id}
GET /v1/experienceGET /v1/experience/{id}POST /v1/experiencePUT /v1/experience/{id}PATCH /v1/experience/{id}DELETE /v1/experience/{id}GET /v1/educationGET /v1/education/{id}POST /v1/educationPUT /v1/education/{id}PATCH /v1/education/{id}DELETE /v1/education/{id}GET /v1/skillsGET /v1/skills/{id}POST /v1/skillsPUT /v1/skills/{id}PATCH /v1/skills/{id}DELETE /v1/skills/{id}GET /v1/usesGET /v1/uses/{id}POST /v1/usesPUT /v1/uses/{id}PATCH /v1/uses/{id}DELETE /v1/uses/{id}GET /v1/shelfGET /v1/shelf/{id}POST /v1/shelfPUT /v1/shelf/{id}PATCH /v1/shelf/{id}DELETE /v1/shelf/{id}
GET /v1/locationGET /v1/location/{id}POST /v1/locationPUT /v1/location/{id}PATCH /v1/location/{id}DELETE /v1/location/{id}GET /v1/location/latest
GET /v1/health- Get daily health metrics (date range)POST /v1/health- Submit daily health metricsGET /v1/health/{date}- Get health data for specific dateDELETE /v1/health/{date}- Delete health data for specific dateGET /v1/health/heart-rate- Get heart rate samplesPOST /v1/health/heart-rate- Submit heart rate samples (single or batch)GET /v1/health/sleep- Get sleep sessionsPOST /v1/health/sleep- Submit sleep sessionGET /v1/health/workouts- Get workout sessionsPOST /v1/health/workouts- Submit workoutGET /v1/health/workouts/{id}- Get workoutPUT /v1/health/workouts/{id}- Update workoutPATCH /v1/health/workouts/{id}- Patch workoutDELETE /v1/health/workouts/{id}- Delete workoutGET /v1/health/summary- Get health summary with recent data and averages
See APPLE_HEALTH_EXPORT.md for detailed health API documentation.
GET /v1/status- Latest Lanyard/Discord statusPOST /v1/status/refresh- Refresh status snapshotGET /v1/wakatime- WakaTime daily summariesPOST /v1/wakatime/refresh- Refresh WakaTime daily dataPOST /v1/wakatime/backfill- Backfill WakaTime daily dataGET /v1/wakatime/hourly- WakaTime hourly dataPOST /v1/wakatime/hourly/refresh- Refresh WakaTime hourly dataPOST /v1/wakatime/hourly/backfill- Backfill WakaTime hourly dataGET /v1/github- GitHub contributionsPOST /v1/github/refresh- Refresh GitHub contributionsPOST /v1/github/backfill- Backfill GitHub contributionsPOST /v1/refresh- Refresh all (status, WakaTime, GitHub)
GET /v1/wrapped/day- Daily wrapped statsGET /v1/wrapped/week- Weekly wrapped statsGET /v1/wrapped/month- Monthly wrapped statsGET /v1/wrapped/2026- 2026 wrapped stats
The API stores JSON fields as *_json text columns in D1.
Example request:
curl -H "Authorization: Bearer $API_TOKEN" https://api.anuragd.me/healthPOST /v1/refreshrefreshes status, WakaTime (daily + hourly), and GitHub if configured.- Backfill endpoints accept JSON like:
{ "start": "2025-01-01", "end": "2025-12-31" }- Install Wrangler and login:
npm installnpx wrangler login
- Create a D1 database:
npx wrangler d1 create personal_api- Copy the
database_idintowrangler.toml.
- Run migrations:
npx wrangler d1 migrations apply personal_api --localnpx wrangler d1 migrations apply personal_api --remote
- Set secrets:
npx wrangler secret put API_TOKEN
- Set Lanyard user id (optional, for status snapshots):
npx wrangler secret put LANYARD_USER_ID
- Set WakaTime API key (optional, for activity snapshots):
npx wrangler secret put WAKATIME_API_KEY
- Set WakaTime timezone (optional, for hourly data):
npx wrangler secret put WAKATIME_TIMEZONE
- Set GitHub username/token (optional, for wrapped stats):
npx wrangler secret put GITHUB_USERNAMEnpx wrangler secret put GITHUB_TOKEN
- Configure R2 (optional, for photo uploads):
- Create an R2 bucket (example:
personal-api-photos). - Set the bucket name in
wrangler.tomlunder[[r2_buckets]]forR2_BUCKET. - Set
R2_PUBLIC_BASE_URLinwrangler.toml(or as a secret) to your public bucket URL.
- Create an R2 bucket (example:
- Deploy:
npx wrangler deploy
wrangler.toml includes a cron trigger to refresh status snapshots every 5 minutes and WakaTime daily/hourly. It also sets API_VERSION, returned by /health.
Link to Lanyard api (JSON): https://api.lanyard.rest/v1/users/{DISCORD_USER_ID}
Use .env.example for local values. Never commit real secrets; set them with wrangler secret put.
npx wrangler dev src/index.ts
POST /v1/photos/upload expects raw image bytes with an image/* content type.
Example:
curl -X POST https://api.anuragd.me/v1/photos/upload \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: image/jpeg" \
--data-binary "@./photo.jpg"