> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mindcase.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Spotify Plays API

> Spotify track play counts with title, artists, album and IDs. Pass track or album URLs.

`POST /v1/data/spotify/plays/run`

**Pricing:** $0.0015 per play ($1.50 per 1,000).

## Request

Send the inputs under `params`. Only the keys below are accepted; any other key returns `422 invalid_params`.

**urls** `string[]` *required*

One or more urls. One request reads them all.

**maxResults** `integer` (default: 100)

How many plays to return in total. Defaults to 100; use 0 for all.

## Example

```bash cURL theme={null}
curl -X POST "https://api.mindcase.co/v1/data/spotify/plays/run?wait=true" \
  -H "Authorization: Bearer $MINDCASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "params": {
    "urls": [
      "https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b?si=abc123",
      "https://open.spotify.com/track/6habFhsOp2NvshLv26DqMb",
      "https://open.spotify.com/intl-hi/track/6VBhH7CyP56BXjp8VsDFPZ"
    ]
  }
}'
```

```python Python theme={null}
import os, requests

r = requests.post(
    "https://api.mindcase.co/v1/data/spotify/plays/run",
    params={"wait": "true"},
    headers={"Authorization": f"Bearer {os.environ['MINDCASE_API_KEY']}"},
    json={"params": {
    "urls": [
        "https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b?si=abc123",
        "https://open.spotify.com/track/6habFhsOp2NvshLv26DqMb",
        "https://open.spotify.com/intl-hi/track/6VBhH7CyP56BXjp8VsDFPZ"
    ]
}},
)
job = r.json()
rows = job.get("data", [])  # if job["status"] == "running", poll /v1/jobs/{job_id}/results
```

```javascript Node.js theme={null}
const r = await fetch("https://api.mindcase.co/v1/data/spotify/plays/run?wait=true", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MINDCASE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ params: {
  "urls": [
    "https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b?si=abc123",
    "https://open.spotify.com/track/6habFhsOp2NvshLv26DqMb",
    "https://open.spotify.com/intl-hi/track/6VBhH7CyP56BXjp8VsDFPZ"
  ]
} }),
});
const job = await r.json();
const rows = job.data ?? []; // if job.status === "running", poll /v1/jobs/{job_id}/results
```

## Response fields

Each row in `data` is one play, keyed by these fields.

| Field | Name | Type |
| - | - | - |
| `trackUrl` | Track URL | url |
| `trackId` | Track ID | text |
| `title` | Title | text |
| `artists` | Artists | array |
| `artistIds` | Artist IDs | array |
| `albumName` | Album Name | text |
| `albumId` | Album ID | text |
| `plays` | Plays | number |
| `durationS` | Duration S | number |
| `releaseDate` | Release Date | date |
| `trackNumber` | Track Number | number |
| `discNumber` | Disc Number | number |
| `explicit` | Explicit | boolean |
| `label` | Label | text |
| `topTrackRank` | Top Track Rank | number |
| `thumbnail` | Thumbnail | image |
| `sourceQuery` | Source Query | text |

## Example response

Abridged: long text and lists are shortened.

```json theme={null}
{
  "job_id": "7f3a1c2e-0b9d-4c55-9a51-3f2e8d1b6a40",
  "agent": "spotify/plays",
  "status": "completed",
  "row_count": 1,
  "truncated": false,
  "data": [
    {
      "releaseDate": "2019-02-01",
      "discNumber": null,
      "durationS": 229.36,
      "artists": [
        "Luis Fonsi",
        "Daddy Yankee"
      ],
      "explicit": false,
      "albumName": "VIDA",
      "trackId": "6habFhsOp2NvshLv26DqMb",
      "label": null,
      "trackNumber": 9,
      "albumId": "5C0YLr4OoRGFDaqdMQmkeH",
      "plays": 2241138551,
      "trackUrl": "https://open.spotify.com/track/6habFhsOp2NvshLv26DqMb",
      "topTrackRank": null,
      "title": "Despacito",
      "thumbnail": "https://i.scdn.co/image/ab67616d00001e02ef0d4234e1a645740f77d59c",
      "sourceQuery": "https://open.spotify.com/track/6habFhsOp2NvshLv26DqMb",
      "artistIds": [
        "4V8Sr092TqfHkfAA5fXXqG",
        "4VMYDCV2IEDYJArk749S6m"
      ]
    }
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.