Docs menu

Spotify track

Beta GET /v1/spotify/track

GET /v1/spotify/track

Title, artists, album, duration, lifetime play count and the 30 second preview URL.

  • 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 ofSpotify track URL. Accepted hosts: open.spotify.com, spotify.com, spotify.link.
idstringone ofSpotify track 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:

  • 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/spotify/track" \
  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \
  --data-urlencode "id=4cOdK2wGLETKBW3PvgPWqT"
Python
import os
import requests

params = {
    "id": "4cOdK2wGLETKBW3PvgPWqT",
}
res = requests.get(
    "https://api.socialscrape.io/v1/spotify/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/spotify/track");
url.search = new URLSearchParams({
  "id": "4cOdK2wGLETKBW3PvgPWqT"
}).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 Spotify track",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.socialscrape.io/v1/spotify/track",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "id",
              "value": "4cOdK2wGLETKBW3PvgPWqT"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
            }
          ]
        }
      }
    }
  ],
  "connections": {}
}

Example response#

This is a sample from a recorded response. Status 200.

{
  "ok": true,
  "credits_charged": 1,
  "credits_remaining": 4999,
  "cached": false,
  "cached_at": null,
  "request_id": "req_11f4ec0529df2dacd8ad851a",
  "data": {
    "object": "song",
    "platform": "spotify",
    "id": "4cOdK2wGLETKBW3PvgPWqT",
    "url": "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
    "title": "Never Gonna Give You Up",
    "artists": [
      "Rick Astley"
    ],
    "album": "Whenever You Need Somebody",
    "duration_seconds": 213.573,
    "cover_url": "https://i.scdn.co/image/ab67616d0000b273baf89eb11ec7c657805d2da0",
    "preview_url": "https://p.scdn.co/mp3-preview/40a780b231e5ed130483bec7917b6c9a4f8a4708",
    "released_at": "1987-11-12",
    "isrc": null,
    "explicit": false,
    "is_original": null,
    "stats": {
      "plays": 1197661434,
      "uses": null,
      "likes": null
    },
    "extra": {
      "album_id": "5Z9iiGl2FcIfa3BMiv6OIw",
      "album_url": "https://open.spotify.com/album/5Z9iiGl2FcIfa3BMiv6OIw",
      "artist_ids": [
        "0gxyHStUsqpMadRV0Di1Qt"
      ],
      "media_type": "AUDIO",
      "playable": true,
      "track_number": 1,
      "uri": "spotify:track:4cOdK2wGLETKBW3PvgPWqT",
      "video_count": 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": "not_found",
    "message": "The platform says this profile, post or item does not exist.",
    "retryable": false
  },
  "credits_charged": 0,
  "request_id": "req_75cf7925af1a824b4491e895"
}