# Spotify Play Count (`spotify.play_count`)

Lifetime stream counts for a Spotify track, every track of an album, or an artist's top tracks, from one URL.

Docs: https://primaryapi.com/docs/api-reference/spotify/play_count

- Endpoint: `POST https://api.primaryapi.com/v1/run/spotify.play_count`
- Category: Audio · Platform: `spotify` · Kind: lookup · Status: live
- Price: 1.13 credits per result, at least 2 credits a call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per result returned, rounded up to whole credits per call (a call that returns nothing costs nothing)
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=spotify.play_count`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `url` | string | yes |  | max 2048 chars | Spotify track, album or artist URL (or spotify: URI) to read stream counts for, e.g. "https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b". |
| `limit` | integer | no | 50 | 1–100 | Maximum track rows to return (1-100, default 50). A track URL returns one row and an artist URL its top 10 tracks; billed per row returned. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `items` | object[] |  |
| `items[].id` | string \| null | Spotify track ID |
| `items[].name` | string \| null |  |
| `items[].url` | string \| null | open.spotify.com track URL |
| `items[].type` | "track" |  |
| `items[].playCount` | integer \| null | All-time Spotify streams (Spotify shows 0 until 1,000 plays) |
| `items[].artistName` | string \| null |  |
| `items[].albumName` | string \| null |  |
| `items[].releaseDate` | string \| null |  |
| `items[].trackNumber` | integer \| null | Position on the album (null for artist top tracks) |
| `items[].durationMs` | integer \| null |  |
| `items[].image` | string \| null |  |
| `items[].previewUrl` | string \| null |  |
| `entityType` | enum | What the URL points to |
| `totalPlayCount` | integer \| null | Album URLs: Spotify's album total when the source gives it; otherwise the sum of the returned rows |
| `nextCursor` | string \| null | Always null: one call returns every row up to `limit` |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/spotify.play_count" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "items": [
        {
          "id": "string",
          "name": "string",
          "url": "https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b",
          "type": "track",
          "playCount": 0,
          "artistName": "string",
          "albumName": "string",
          "releaseDate": "string",
          "trackNumber": 0,
          "durationMs": 0,
          "image": "string",
          "previewUrl": "https://example.com"
        }
      ],
      "entityType": "track",
      "totalPlayCount": 0,
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 2,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 1.13 credits per result, at least 2 credits a call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=spotify.play_count`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Legal

Spotify terms bar scraping; play counts come from public web-player data, not the official Web API. Cover art is copyrighted: links are passed through, nothing is re-hosted.

