Before you start
- Get an API keySign up for 100 free credits, no card. Keys start with
gs_live_. - Put it in the environmentEvery example reads it from
GROUNDSOCIAL_API_KEY:export GROUNDSOCIAL_API_KEY=gs_live_… - Set up JavaScript
node --version # 18 or newer: fetch is built in, nothing to install
Call TikTok top videos API from JavaScript
GET /v1/tiktok/trending/videos. Save this as main.mjs and run node main.mjs. It reads the items in entityInfos and prints itemInfo.title and itemAuthorMetrics.followers for each.
// main.mjs: Node.js 18+, no dependencies
const url = new URL('https://api.groundsocial.dev/v1/tiktok/trending/videos')
url.searchParams.set('country', 'US')
url.searchParams.set('period', '7')
const res = await fetch(url, {
headers: {
Authorization: `Bearer ${process.env.GROUNDSOCIAL_API_KEY}`,
},
signal: AbortSignal.timeout(60_000),
})
if (!res.ok) {
const { error } = await res.json()
throw new Error(`${error.code}: ${error.hint ?? error.message}`)
}
const data = await res.json()
for (const item of data.entityInfos) {
console.log(item.itemInfo?.title, item.itemAuthorMetrics?.followers)
}
console.log('credits charged:', res.headers.get('x-credits-charged'))The response
A real TikTok response to this call, recorded from the live source and shortened for display: arrays keep their first items and … marks every cut. The recorded page had 2 items in entityInfos. Live calls return current data in the same shape.
{
"entityInfos": [
{
"itemInfo": {
"itemID": "7691731357294152974",
"authorID": "7532541110103867406",
"contentType": 1,
"coverURL": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-p-0068-tx/oogoQFgR5EB6M0TqAyC2QhQefQE…",
"coverURLList": [
{
"…": "2 fields"
},
{
"…": "2 fields"
}
],
"createTime": "1790870796",
"creatorID": "6992810747127628805",
"title": "AD sparkling through the city, as part of #thediamondcollective @The Diamond Collective ",
"videoURL": "https://v16m-default.tiktokcdn-us.com/bc115036eff2290f90ca4abccb5c97e0/6b067eb5/video/tos/…"
},
"itemAuthorInfo": {
"avatarURI": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/5a124cccf2dadf0c7e34d0f4a…",
"bio": "NYC\nArtist--multicurious lover\n⭐️subscribe to my youtube⭐️\nsebin@dulcedo.com",
"handlerName": "deathstatequilibrium",
"nickName": "sebin🌟"
},
"itemMetrics": {
"engagementRate": 0.0004565897757430412,
"engagementRateLifeTime": 0.0007131562268624228,
"organicVideoViews": "5017483",
"organicVideoViewsLifeTime": "31217086",
"sixSecondsVTR": 0.009636825498597203,
"sixSecondsVTRLifeTime": 0.011701371964817882,
"videoViews": "51878078",
"videoViewsLifeTime": "234968151"
},
"itemAuthorMetrics": {
"followers": "117256"
}
},
{
"itemInfo": {
"itemID": "7678479724896587038",
"authorID": "7070293872819044358",
"contentType": 1,
"coverURL": "https://p16-common-sign.tiktokcdn-us.com/tos-useast8-p-0068-tx2/ocK3E0iPwBkRoAA5XXAPvCEAiB…",
"coverURLList": [
{
"…": "2 fields"
},
{
"…": "2 fields"
}
],
"createTime": "1787785387",
"creatorID": "6880574638150697990",
"title": "Five years ago, I started my small business with no idea what it would grow into. From wor…",
"videoURL": "https://v16m-default.tiktokcdn-us.com/37a23ad1f71c39e1dfd697f1ad694d53/6b067ec4/video/tos/…"
},
"itemAuthorInfo": {
"avatarURI": "https://p16-common-sign.tiktokcdn-us.com/tos-useast8-avt-0068-tx2/7d6ee80f6e94a044a88786ee…",
"bio": "your favorite hand-drawn crewnecks & tees\n🧸🤍🎨\nentrepreneur & nurse\nShop Below ◡̈",
"handlerName": "megannco",
"nickName": "Meg Ann Co."
},
"itemMetrics": {
"engagementRate": 0.0013633322396169325,
"engagementRateLifeTime": 0.0016093465367882222,
"organicVideoViews": "5187904",
"organicVideoViewsLifeTime": "19207771",
"sixSecondsVTR": 0.030609222943414737,
"sixSecondsVTRLifeTime": 0.03216759125618045,
"videoViews": "42046244",
"videoViewsLifeTime": "195686257"
},
"itemAuthorMetrics": {
"followers": "271347"
}
}
],
"periodEndTimestamp": "1795392000",
"page": 1,
"hasMore": false
}Top-level fields
| Field | Type | Description |
|---|---|---|
entityInfos | object[] | – |
periodEndTimestamp | string | – |
page | number | – |
hasMore | boolean | – |
Parameters
| Name | In | Type | Description |
|---|---|---|---|
country | query | string | Market (default US). |
period | query | "7" | "30" | Days: 7 (default) or 30. One of 7, 30. |
order | query | "views" | "engagement" | "completion" | views (default), engagement or completion. One of views, engagement, completion. |
page | query | integer | Page, from 1. |
Errors and retries
Every error is JSON with error.code (stable: branch on it), message, hint (what to do next), docs_url and retryable. A failed call is never charged. Retry only when retryable is true, after the Retry-After header.
async function call(url, init = {}, attempt = 0) {
const res = await fetch(url, {
...init,
headers: { Authorization: `Bearer ${process.env.GROUNDSOCIAL_API_KEY}`, ...init.headers },
signal: AbortSignal.timeout(60_000),
})
if (res.ok) return res.json()
const { error } = await res.json()
// Branch on error.code (stable); error.hint says what to do next.
if (error.retryable && attempt < 2) {
const wait = Number(res.headers.get('retry-after') ?? 2)
await new Promise((r) => setTimeout(r, wait * 1000))
return call(url, init, attempt + 1)
}
throw Object.assign(new Error(error.hint ?? error.message), { code: error.code })
}| Status | Meaning |
|---|---|
200 | The video board. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The account, video, comment, hashtag or sound does not exist on TikTok, or was removed. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | TikTok is temporarily unavailable. Retryable; nothing was charged. |
Every error code and what to do about it.
Pricing
| Cost | |
|---|---|
| Per call | 1 credit per call |
| 1,000 calls | $1.00 on the starter pack, $0.40 at volume |
| No key (MPP or x402) | $0.01 per call |
| Failed call | Refunded, never charged |
Every response has x-credits-charged and x-credits-remaining headers. Credits never expire. Packs and calculator.
From an AI agent (MCP)
The same call is the tiktok_videos_popular tool on the hosted MCP server, so Claude, Cursor or any MCP client can make it without code. Add the server once:
claude mcp add --transport http groundsocial https://api.groundsocial.dev/mcpThen ask for it in words (“TikTok’s top-videos board for a market and period”), or call the tool directly:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "tiktok_videos_popular",
"arguments": {
"country": "US",
"period": "7"
}
}
}MCP setup for Claude Desktop, Cursor, VS Code and ChatGPT.
Study what wins
Read the top videos weekly and note their formats and sounds.
Questions
Which markets?
TikTok publishes this board for the US, Japan, Vietnam, Thailand and Indonesia.
Keep going
- This call in Python, TypeScript, Go, PHP, cURL.
- TikTok top videos API reference: every field and status code.
- TikTok tutorials and all JavaScript tutorials.
- TikTok API: every endpoint and price.
- How to scrape TikTok hashtag videos with JavaScript: Videos with a TikTok hashtag, about 30 a page.
- How to scrape TikTok sound videos with JavaScript: Videos using a TikTok sound, about 30 a page.
- How to scrape TikTok search suggestions with JavaScript: What TikTok’s search box suggests for a partial query.
- How to scrape TikTok search with JavaScript: TikTok videos for a keyword, 16 a page.
- How to scrape TikTok place videos with JavaScript: Videos tagged at a TikTok place, 30 a page.
- How to scrape TikTok effect videos with JavaScript: Videos made with a TikTok effect, 30 a page.
Run it on your own data
One key for TikTok and 76 more platforms, over REST or MCP. Free credits on signup, no card.
TikTok is a trademark of ByteDance Ltd. We are not affiliated with or endorsed by TikTok or ByteDance.