Monitor Spotify Streams & Daily Deltas via the streamcounts.xyz Free API.

Query historical stream totals & daily deltas on any track or album you want. Start tracking new, missing, or niche songs/albums by crafting your own tracking playlist.

Note: The entire streamcounts.xyz backend, SQLite tracking engine, and API were manually built from scratch.

Important API Mechanics & Quirks

1

URI-Sensitive Tracking

The database tracks exact Spotify URIs. Different album versions (Standard vs. Deluxe vs. Single) maintain separate database entries unless aggregated.

2

Public Playlist Ingestion

To track missing songs or ensure an artist's full catalog is indexed, put the tracks in a public Spotify playlist and submit its ID to /api/v1/new-playlist/:id.

!

Stringified Nested JSON

In track responses, the album and artists fields are returned as escaped JSON strings. Always run JSON.parse() on them in your client!

Plug & Play Developer Prompt

AI-Tailored Integration Guide

Copy this prompt and paste it directly into ChatGPT, Claude, Cursor, or Gemini along with your project context to automatically wire up this API.

PROMPT_FOR_AI_CODING_ASSISTANT.md Ready to paste
I want you to integrate the streamcounts.xyz Open Spotify Stream Tracking API into my application. 

### API Base URL
Use `https://streamcounts.xyz` (or configure via an environment variable like `API_BASE_URL`). No API key or authentication headers are required.

### Core Rules & Data Parsing Requirements (CRITICAL)
1. **URI Sensitivity:** All IDs are standard 22-character Spotify Base62 IDs (e.g., `6LqNN22kT3074XbTVUrhzX`).
2. **Double-Parse Stringified JSON Fields:** In endpoints returning track objects (`/artist-tracks`, `/album-tracks`, `/track-details`), the `album` and `artists` properties are returned as **JSON-encoded strings** rather than native objects/arrays. You MUST wrap them in `JSON.parse()` (with a fallback try/catch) before accessing `album.cover`, `album.name`, or mapping over `artists` (`role: "0"` = primary artist, `role: "1"` = featured artist).
3. **Album Track Completeness:** `/api/v1/album-tracks/:id` may return tracks out of tracklist order. Always cross-reference the array length against `album.track_count` from `/api/v1/album/:id` to verify if all tracks on that URI are tracked.
4. **Error Handling:** Missing resources return HTTP 200 with `"typename": "__notFound"` and a `message` field. Check `data.typename === "__notFound"` in your fetch wrapper.

### Available Endpoints

1. **Get Artist Info**
   - `GET https://streamcounts.xyz/api/v1/artist/:artistId`
   - Success (`typename: "__artist"`): `{ typename, artist: { id, name } }`

2. **Get All Tracked Songs for an Artist (Auto-Deduped)**
   - `GET https://streamcounts.xyz/api/v1/artist-tracks/:artistId`
   - Success (`typename: "__artistTracks"`): `{ typename, tracks: [{ id, name, total, daily, date, album (JSON string), artists (JSON string) }] }`

3. **Get Album Overview & Aggregate Streams**
   - `GET https://streamcounts.xyz/api/v1/album/:albumId`
   - Success (`typename: "__albumOverview"`): `{ typename, album: { album (JSON string), total, daily, track_count } }`

4. **Get Album Tracklist with Stream Counts**
   - `GET https://streamcounts.xyz/api/v1/album-tracks/:albumId`
   - Success (`typename: "__albumTracks"`): `{ typename, tracks: [{ id, name, total, daily, date, artists (JSON string) }] }`

5. **Get Historical Daily Stream Time-Series for a Track**
   - `GET https://streamcounts.xyz/api/v1/track-history/:trackId`
   - Success (`typename: "__trackHistory"`): `{ typename, data: [{ total, daily, date }] }` (Ordered newest to oldest)

6. **Get Single Track Details**
   - `GET https://streamcounts.xyz/api/v1/track-details/:trackId`
   - Success (`typename: "__track"`): `{ typename, track: { id, name, total, daily, date, artist_name, artists (JSON string), album (JSON string) } }`

7. **Submit a Public Playlist to Ingest/Track New Songs**
   - `GET https://streamcounts.xyz/api/v1/new-playlist/:playlistId`
   - Helper note: Extract the 22-character playlist ID if the user pastes a full `open.spotify.com/playlist/...` URL. Playlist MUST be public.
   - Response (`typename: "__playlistAddResponse"`): `{ typename, message }`

### Your Task
Create a clean, typed API client/service module in my codebase with helper functions for all 7 endpoints above, automatically parsing the stringified `album` and `artists` fields, handling `__notFound` responses, and including a URL-to-ID parser for submitting playlists.

API Endpoint Reference

Base URL: https://streamcounts.xyz • All endpoints return application/json with a root typename discriminator.

GET /api/v1/artist/:id
Fetch basic artist metadata
Success Response
{
  "typename": "__artist",
  "artist": {
    "id": "6LqNN22kT3074XbTVUrhzX",
    "name": "Kesha"
  }
}
Not Found Response
{
  "typename": "__notFound",
  "message": "Artist with that id could not be found.",
  "artist": {}
}
GET /api/v1/artist-tracks/:id
Auto-deduped tracks for an artist
Pro Tip: If an artist's tracks are missing, add all of their tracks into a new public playlist and submit the playlist ID via /api/v1/new-playlist/:id.
Success Response
{
  "typename": "__artistTracks",
  "tracks": [
    {
      "id": "0BMgkRvlTsZrit5S1ysx4n",
      "name": "TiK ToK",
      "total": 2003084336,
      "daily": 780403,
      "date": "2026-11-28",
      "album": "{\"id\":\"5hs0wQFqXp1fNdkchK5wyE\",\"name\":\"Animal\",\"cover\":\"https://...\"}",
      "artists": "[{\"id\":\"6LqNN22kT3074XbTVUrhzX\",\"name\":\"Kesha\",\"role\":\"0\"}]"
    }
  ]
}
Not Found Response
{
  "typename": "__notFound",
  "message": "Artist with that id could not be found.",
  "tracks": []
}
GET /api/v1/album/:id
Aggregate album stream totals & track count
{
  "typename": "__albumOverview",
  "album": {
    "album": "{\"id\":\"6fpLLJsDSSAlToEDW2jv4F\",\"name\":\"Animal (Expanded Edition)\",\"cover\":\"https://...\"}",
    "total": 3520342140,
    "daily": 1425075,
    "track_count": 18
  }
}
GET /api/v1/album-tracks/:id
Individual track stats for a specific album URI
Note: Tracks may not be returned in official tracklist order. Verify completeness by comparing tracks.length against track_count from /api/v1/album/:id.
{
  "typename": "__albumTracks",
  "tracks": [
    {
      "id": "0HPD5WQqrq7wPWR7P7Dw1i",
      "name": "TiK ToK",
      "total": 2003084336,
      "daily": 780403,
      "date": "2026-11-28",
      "artists": "[{\"id\":\"6LqNN22kT3074XbTVUrhzX\",\"name\":\"Kesha\",\"role\":\"0\"}]"
    }
  ]
}
GET /api/v1/track-history/:id
Historical daily stream snapshots
{
  "typename": "__trackHistory",
  "data": [
    {
      "total": 358176562,
      "daily": 189552,
      "date": "2026-11-28"
    },
    {
      "total": 357987010,
      "daily": 190001,
      "date": "2026-11-27"
    }
  ]
}
GET /api/v1/track-details/:id
Latest stream snapshot & metadata for a single track
{
  "typename": "__track",
  "track": {
    "id": "0WCiI0ddWiu5F2kSHgfw5S",
    "name": "Take It Off",
    "total": 358176562,
    "daily": 189552,
    "date": "2026-11-28",
    "artist_name": "kesha",
    "artists": "[{\"id\":\"6LqNN22kT3074XbTVUrhzX\",\"name\":\"Kesha\",\"role\":\"0\"}]",
    "album": "{\"id\":\"6fpLLJsDSSAlToEDW2jv4F\",\"name\":\"Animal (Expanded Edition)\",\"cover\":\"https://...\"}"
  }
}
GET /api/v1/new-playlist/:id
Submit public playlist for ingestion
{
  "typename": "__playlistAddResponse",
  "message": "Added playlist to database. If it is not a valid playlist id, it will not work."
}