Docs menu

Apple Music track

Beta GET /v1/apple-music/track

GET /v1/apple-music/track

Title, artists, album, duration, ISRC, composer and the 30 second preview. A track link on an album page ends in ?i=<song id>; that id is the song's.

  • Cost: 1 credit
  • Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
  • Cache: Results are kept up to 30 days; send max_age_days to reuse them for free.
  • Timeout: A request still running after about 25 seconds answers 202 with a job to poll (Batch and jobs).

Parameters#

NameTypeRequiredDescription
urlURLone ofApple Music song URL. Accepted hosts: music.apple.com.
idstringone ofApple Music song id.

Send at least one of url, id. If you send several, the first listed is used and the rest are ignored.

Every request also accepts:

  • region: two-letter country code for results that vary by country. Changing it restarts the cursor chain.
  • trim: true for a smaller response without null fields and extra.
  • raw: true to also get the platform's original object as raw.
  • max_age_days: accept a cached result up to this many days old, for 0 credits (Caching).

Example request#

Set your key in the environment first (see Authentication).

curl
curl -G "https://api.socialscrape.io/v1/apple-music/track" \
  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \
  --data-urlencode "id=1468058169"
Python
import os
import requests

params = {
    "id": "1468058169",
}
res = requests.get(
    "https://api.socialscrape.io/v1/apple-music/track",
    headers={"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]},
    params=params,
)
body = res.json()

if body["ok"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
TypeScript
const url = new URL("https://api.socialscrape.io/v1/apple-music/track");
url.search = new URLSearchParams({
  "id": "1468058169"
}).toString();
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! },
});
const body = await res.json();

if (body.ok) {
  console.log(body.data);
} else {
  console.error(body.error.code, body.error.message);
}
n8n
{
  "nodes": [
    {
      "name": "SocialScrape Apple Music track",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.socialscrape.io/v1/apple-music/track",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "id",
              "value": "1468058169"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
            }
          ]
        }
      }
    }
  ],
  "connections": {}
}

Example response#

This is a sample from a recorded response, lists and long text are shortened. Status 200.

{
  "ok": true,
  "credits_charged": 1,
  "credits_remaining": 4999,
  "cached": false,
  "cached_at": null,
  "request_id": "req_d8c814d2f32115bfd96e3add",
  "data": {
    "object": "song",
    "platform": "apple_music",
    "id": "1468058169",
    "url": "https://music.apple.com/us/album/i-forgot-that-you-existed/1468058165?i=1468058169",
    "title": "I Forgot That You Existed",
    "artists": [
      "Taylor Swift"
    ],
    "album": "Lover",
    "duration_seconds": 170.651,
    "cover_url": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/49/3d/ab/493dab54-f920-9043-6181-80993b8116c9/19UMGIM53909.rgb.jpg/1200x1200bb.jpg",
    "preview_url": "https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview221/v4/9c/e2/97/9ce2976a-b1c8-aa80-3e94-f4562cbad53e/mzaf_13898706762824220632.plus.aac.ep.m4a",
    "released_at": "2019-08-23",
    "isrc": "USUG11901471",
    "explicit": false,
    "is_original": null,
    "stats": {
      "plays": null,
      "uses": null,
      "likes": null
    },
    "extra": {
      "album_artist": "Taylor Swift",
      "album_id": "1468058165",
      "album_url": "https://music.apple.com/us/album/lover/1468058165",
      "artist_ids": [
        "159260351"
      ],
      "audio_locale": "en-US",
      "audio_traits": [
        "atmos",
        "lossless",
        "lossy-stereo"
      ],
      "composer": "Taylor Swift, Louis Bell & Adam Feeney",
      "disc_number": 1,
      "genres": [
        "Pop",
        "Music"
      ],
      "has_lyrics": true,
      "has_time_synced_lyrics": true,
      "is_apple_digital_master": true,
      "track_number": 1
    }
  },
  "cursor": null,
  "has_more": null
}

Response#

A Song object in data.

See Data models for every field. The envelope around data is described in Responses.

Errors#

Failures are free: credits_charged is 0. Branch on error.code, never on the message.

CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
unsupported_url400noThe URL is not one this endpoint accepts (wrong platform or form).
not_found404noThe platform says this profile, post or item does not exist.

Every request can also fail with the account and platform errors listed on the Errors page.

Example error:

{
  "ok": false,
  "error": {
    "code": "unsupported_url",
    "message": "The URL is not one this endpoint accepts (wrong platform or form).",
    "retryable": false
  },
  "credits_charged": 0,
  "request_id": "req_95a1deadd6bea5c1b8414bd5"
}