The job
A track takes off when many videos use it. List the videos on a sound, then read the track and artist from a streaming catalogue.
Endpoints
| Endpoint | Returns | Cost |
|---|---|---|
GET /v1/tiktok/song | TikTok song details | 1 credit |
GET /v1/tiktok/song/videos | TikTok videos using a song | 1 credit |
GET /v1/spotify/search | Spotify search | 1 credit |
GET /v1/spotify/track | Spotify track | 1 credit |
GET /v1/spotify/artist | Spotify artist | 1 credit |
Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.
Recipe
- Open the sound on TikTok.
- List the videos that use it.
- Search the same title on Spotify.
Preview
The API is in early access. Calls use
api.socialscrape.io and return the shapes in the reference.Python
import os
import requests
API = "https://api.socialscrape.io"
HEADERS = {"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]}
def get(path, **params):
res = requests.get(API + path, headers=HEADERS, params=params, timeout=60)
res.raise_for_status()
return res.json()["data"]
# Spotify search
found = get("/v1/spotify/search", query="Espresso", type="track")
# Spotify track
track = get("/v1/spotify/track", url=found["items"][0]["url"])
print(track)TypeScript
const API = "https://api.socialscrape.io";
const headers = { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! };
async function get(path: string, params: Record<string, string | number | boolean>) {
const query = new URLSearchParams(Object.entries(params).map(([k, v]) => [k, String(v)]));
const res = await fetch(`${API}${path}?${query}`, { headers });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
return (await res.json()).data;
}
// Spotify search
const found = await get("/v1/spotify/search", { query: "Espresso", type: "track" });
// Spotify track
const track = await get("/v1/spotify/track", { url: found.items[0].url });
console.log(track);Good to know
Replace the example title with your own. Counts on a TikTok sound are what the platform shows publicly at the time.