# Wasted on Destiny API This API is a lot simpler than the old one, as there is no longer a need for backend calls to get time data from Bungie. Calls are now made directly from the browser on the website. However, some small things still remain and need an API: dialog content, Patreon supporters logging, and leaderboard queries and saving. For that purpose, there are still some routes available on this new API. Public routes: - GET / -> This page - GET /health -> Service status (database, event loop delay, profile queue, memory) - GET /profile/{membershipId} -> Time played, rank and aggregates (completions, seasonal time, etc.). Also logs the player to the leaderboard - GET /profile/{membershipId}/stream -> Same as above as a server-sent events stream (`progress`, `account`, `aggregates`, `done`, `error`), so the loading progress can be shown - GET /leaderboard/{page}?sorting={timePlayed|timeWasted|triumph|seals} -> Leaderboard, 10 players per page - GET /news?include={tag} -> Active dialogs for the given tag - GET /supporters -> Patreon supporters by tier Profile loading: - Fetching a profile can take a while, as the activity history is downloaded from Bungie. Only a few profiles are computed at the same time (3 by default), and identical requests share one computation. - `/profile` waits at most 15 seconds. If the profile is not ready by then, it answers `202` with `{ "status": "pending" }` and a `Retry-After` header, and the computation continues in the background. Retry after that delay to get the result. - The stream follows the computation until it ends. If every stream client disconnects and no `/profile` request is waiting for it, the computation is cancelled. - A profile result is kept in memory for 5 minutes, and responses are cached by the CDN for 1 hour. - `/health` reports `profiles.oldestQueuedMs` (wait of the oldest queued profile) and `profiles.longestRunningMs` (duration of the longest running computation). Each computation logs a `[PROFILE]` line with its wait, run time, Bungie calls, downloaded size and database time. - When the server is too busy, or Bungie is too slow, `/profile` answers `503` with a `Retry-After` header (in seconds). The stream sends an `error` event instead. Retry after that delay. - Bungie rate limiting is reported as `429`. If you need help with the API, or would like to have new things implemented (unlikely), please hit me up on my Discord server: https://discord.wastedondestiny.com