# List TikTok's music for an account

TikTok's top 100 trending commercial tracks, rank 1 first, for the country you name, else the account's own country, else TikTok's global chart. GET /accounts/{accountId}/music.

`GET https://api.tiktornado.com/api/v1/accounts/{accountId}/music`

Scope: `accounts:read`.

TikTok's top 100 trending commercial tracks, rank 1 first, for the country you name, else the account's own country, else TikTok's global chart. A track's `id` is what a post's `settings.music.trackId` takes. Names and artists come from TikTok. TikTok is asked live.

## Path parameters

- `accountId` string, required: The account, from `GET /accounts`. Matches `^[A-Za-z0-9]{1,64}$`.

## Query parameters

- `country` string: Two capital letters, for example `GB`. The account's own country if left out. Matches `^[A-Z]{2}$`.

## Examples

```bash
curl 'https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/music?country=US' \
  -H "Authorization: Bearer $TIKTORNADO_API_KEY"
```

```js
const response = await fetch("https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/music?country=US", {
  headers: {
    Authorization: `Bearer ${process.env.TIKTORNADO_API_KEY}`,
  },
});
const data = await response.json();
```

```python
import os

import requests

response = requests.get(
    "https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/music",
    headers={
        "Authorization": f"Bearer {os.environ['TIKTORNADO_API_KEY']}",
    },
    params={
        "country": "US",
    },
)
data = response.json()
```

## Response 200

The tracks.

- `tracks` array of objects, required: At most 100 items.
  - `id` string, required: Pass it as `settings.music.trackId`.
  - `name` string, required
  - `artist` string, required: The artist, or an empty string when TikTok gives none.
  - `durationSec` number or null, required: The track's length in seconds, or `null` when TikTok doesn't say.
  - `rank` number, required: Its place in the chart, 1 first.
  - `genres` array of strings, required
  - `previewUrl` string or null, required: An `https` link to a short audio preview, or `null`. A URL.
  - `coverUrl` string or null, required: An `https` link to the track's cover image, or `null`. A URL.

```json
{
  "tracks": [
    {
      "id": "7312345678901234567",
      "name": "Golden Hour",
      "artist": "The Lanterns",
      "durationSec": 15,
      "rank": 1,
      "genres": [
        "pop"
      ],
      "previewUrl": "https://audio.example.com/previews/golden-hour.mp3",
      "coverUrl": "https://images.example.com/covers/golden-hour.jpeg"
    },
    {
      "id": "7312345678901234568",
      "name": "Night Drive",
      "artist": "Kilo Park",
      "durationSec": null,
      "rank": 2,
      "genres": [],
      "previewUrl": null,
      "coverUrl": null
    }
  ]
}
```

## Errors

| Status | Reason | Message |
| --- | --- | --- |
| 400 | `invalid_request` | Something here isn't valid. Check it and try again. |
| 400 | `account_not_ready` | This account isn't ready to post yet. Or: This account is under review by TikTok, so new posts can't be scheduled right now. |
| 400 | `invalid_state` | This can't be done right now. Refresh and try again. |
| 400 | `account_reconnecting` | This account is being reconnected. Your post will go out once it's back. |
| 401 | `api_key_invalid` | This API key isn't valid. Check it, or create a new one in the app. |
| 403 | `access_locked` | Your subscription isn't active, so this can't be changed right now. Visit Billing to fix it. |
| 403 | `api_scope_missing` | This API key can't do this. Create a key with the access it needs in the app. |
| 404 | `not_found` | We couldn't find this. |
| 429 | `slow_down` | You're going a bit fast. Wait a moment and try again. |
| 500 | `unknown_error` | Something went wrong on our side. We're on it. |
| 503 | `service_unavailable` | Something went wrong on our side. We're on it. |