Spotify search
Beta GET /v1/spotify/search
GET /v1/spotify/search
Tracks, artists, albums, playlists, podcasts, episodes and audiobooks. Without type every kind is returned, 10 of each; with type, 20 of that kind. Use type=show to find podcast ids. Episodes come back as songs with extra.type "episode", audiobooks as collections. Results follow the country of the server's IP; region is accepted but does not change them.
- 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_daysto reuse them for free. - Timeout: A request still running after about 25 seconds answers
202with a job to poll (Batch and jobs).
Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
query | string | yes | Search terms. Also accepted as keyword, q. |
type | string | no | Kind of result. One of track, album, artist, playlist, show, episode, audiobook. Also accepted values: podcast for show, podcasts for show, tracks for track, albums for album, artists for artist, playlists for playlist, episodes for episode, audiobooks for audiobook. |
Every request also accepts:
cursor: the cursor from the previous page (Pagination).region: two-letter country code for results that vary by country. Changing it restarts the cursor chain.trim:truefor a smaller response withoutnullfields andextra.raw:trueto also get the platform's original object asraw.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 -G "https://api.socialscrape.io/v1/spotify/search" \
-H "x-api-key: $SOCIALSCRAPE_API_KEY" \
--data-urlencode "query=taylor swift"import os
import requests
params = {
"query": "taylor swift",
}
res = requests.get(
"https://api.socialscrape.io/v1/spotify/search",
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"])const url = new URL("https://api.socialscrape.io/v1/spotify/search");
url.search = new URLSearchParams({
"query": "taylor swift"
}).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);
}{
"nodes": [
{
"name": "SocialScrape Spotify search",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
0,
0
],
"parameters": {
"method": "GET",
"url": "https://api.socialscrape.io/v1/spotify/search",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "query",
"value": "taylor swift"
}
]
},
"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_30b540ee571e072da05cb2f3",
"data": {
"object": "list",
"items": [
{
"object": "song",
"platform": "spotify",
"id": "5xTtaWoae3wi06K5WfVUUH",
"url": "https://open.spotify.com/track/5xTtaWoae3wi06K5WfVUUH",
"title": "Shake It Off",
"artists": [
"Taylor Swift"
],
"album": "1989",
"duration_seconds": 219.2,
"cover_url": "https://i.scdn.co/image/ab67616d0000b2739abdf14e6058bd3903686148",
"preview_url": null,
"released_at": null,
"isrc": null,
"explicit": false,
"is_original": null,
"stats": {
"plays": null,
"uses": null,
"likes": null
},
"extra": {
"album_id": "2QJmrSgbdM35R67eoGQo4j",
"artist_ids": [
"06HL4z0CvFAxyc27GXpf02"
],
"playable": true,
"uri": "spotify:track:5xTtaWoae3wi06K5WfVUUH",
"video_count": 1
}
},
{
"object": "song",
"platform": "spotify",
"id": "3GCL1PydwsLodcpv0Ll1ch",
"url": "https://open.spotify.com/track/3GCL1PydwsLodcpv0Ll1ch",
"title": "You Belong With Me",
"artists": [
"Taylor Swift"
],
"album": "Fearless",
"duration_seconds": 231.133,
"cover_url": "https://i.scdn.co/image/ab67616d0000b2737b25c072237f29ee50025fdc",
"preview_url": null,
"released_at": null,
"isrc": null,
"explicit": false,
"is_original": null,
"stats": {
"plays": null,
"uses": null,
"likes": null
},
"extra": {
"album_id": "2dqn5yOQWdyGwOpOIi9O4x",
"artist_ids": [
"06HL4z0CvFAxyc27GXpf02"
],
"playable": true,
"uri": "spotify:track:3GCL1PydwsLodcpv0Ll1ch",
"video_count": 1
}
}
],
"cursor": "eyJvIjoxMH0",
"has_more": true,
"parent": null
},
"cursor": "eyJvIjoxMH0",
"has_more": true
}Response#
A list of Song or Album or Profile or Collection objects in data.items, with data.cursor and data.has_more.
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.
| Code | HTTP | Retry | Meaning |
|---|---|---|---|
invalid_params | 400 | no | A parameter is missing, unknown or has the wrong type. |
not_found | 404 | no | The 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.
Related endpoints#
- Spotify artist (
GET /v1/spotify/artist) - Spotify album (
GET /v1/spotify/album) - Spotify track (
GET /v1/spotify/track) - Spotify podcast (
GET /v1/spotify/podcast) - Spotify playlist (
GET /v1/spotify/playlist) - Spotify podcast episodes (
GET /v1/spotify/podcast/episodes)