SocialCrawl

Docs for agents

TypeScript source of truth

The calls to copy when an agent uses SocialCrawl from TypeScript, with a simple and a complex example for each

This page is for an agent that writes SocialCrawl calls in TypeScript. Copy an example, change the values, and run it. Each family below shows one simple and one complex call.

Install

Node.js 22.18 or later runs the examples as .mts files with node socialcrawl.mts. There is nothing to install. On an older Node, run them with npx tsx socialcrawl.mts.

Authenticate

Send your key in the x-api-key header on every call. Keep it in SOCIALCRAWL_API_KEY, out of your code.

Terminal
export SOCIALCRAWL_API_KEY=sc_your_key_here

Check the key with the balance call. It is free.

socialcrawl.mts
const res = await fetch("https://www.socialcrawl.dev/v1/credits/balance", {
  headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
});
console.log(await res.json());

When to use what

Pick the call by the job. Every row links its section. The price of each call is on Endpoint pricing, and the other calls are in the API reference.

JobCallSection
Read one account: name, followers, bioGET /v1/tiktok/profileGet a profile
Read an account's recent posts, page by pageGET /v1/tiktok/profile/videosGet posts one page at a time
Ask one question of many platforms at onceGET /v1/search/everywhereSearch many platforms
Price any call before you send itGET /v1/utility/estimatePrice a call before you send it

Get a profile

Why use it

Use it to read one account. You send a handle and get the name, the follower count and the bio. Other platforms answer in the same shape, so you change the platform in the path and nothing else.

Preferred call

GET /v1/tiktok/profile. Pass handle. Add counts=web for the counts the website shows.

Simple example

One call, no error handling.

socialcrawl.mts
const url = new URL("https://www.socialcrawl.dev/v1/tiktok/profile");
url.searchParams.set("handle", "charlidamelio");
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
});
const body = await res.json();
console.log(body.data);

Complex example

Adds more params. A failed call raises an error that names its error.type.

socialcrawl.mts
// Send one request. Throw with error.type and error.doc_url when success is false.
async function send(url: URL) {
  const res = await fetch(url, {
    headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
  });
  const body = await res.json();
  if (!body.success) {
    const { type, message, doc_url } = body.error;
    throw new Error(`${type}: ${message} (${doc_url})`);
  }
  return body;
}

const url = new URL("https://www.socialcrawl.dev/v1/tiktok/profile");
url.searchParams.set("handle", "charlidamelio");
url.searchParams.set("counts", "web");
const answer = await send(url);
console.log(answer.data.author.followers, answer.credits_used);

Parameters

NameWhat it does
handleTikTok username without the @ symbol.
user_idTikTok numeric user ID.
countsapp (default) or web.

Get posts one page at a time

Why use it

Use it to read an account's recent videos. Each answer holds one page. To read the next page, send pagination.next_cursor back as cursor. Stop when pagination.has_more is false.

Preferred call

GET /v1/tiktok/profile/videos. Pass handle. Add since to stop at a date.

Simple example

One call, no error handling.

socialcrawl.mts
const url = new URL("https://www.socialcrawl.dev/v1/tiktok/profile/videos");
url.searchParams.set("since", "2026-09-01");
url.searchParams.set("handle", "charlidamelio");
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
});
const body = await res.json();
console.log(body.data.items.length, body.pagination.next_cursor);

Complex example

Reads two pages and stops early when there is no next page. A failed call raises an error that names its error.type.

socialcrawl.mts
// Send one request. Throw with error.type and error.doc_url when success is false.
async function send(url: URL) {
  const res = await fetch(url, {
    headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
  });
  const body = await res.json();
  if (!body.success) {
    const { type, message, doc_url } = body.error;
    throw new Error(`${type}: ${message} (${doc_url})`);
  }
  return body;
}

const url = new URL("https://www.socialcrawl.dev/v1/tiktok/profile/videos");
url.searchParams.set("handle", "charlidamelio");
for (const page of [1, 2]) {
  const answer = await send(url);
  const { next_cursor, has_more } = answer.pagination;
  console.log(page, answer.data.items.length, next_cursor);
  if (!has_more) break;
  url.searchParams.set("cursor", next_cursor);
}

Parameters

NameWhat it does
handleTikTok username without the @ symbol
user_idTikTok user id.
sinceOnly videos published on or after this date: YYYY-MM-DD (midnight UTC) or an ISO 8601 timestamp.
cursorThe pagination.next_cursor of the page before. Leave it out for the first page.

Search many platforms

Why use it

Use it to ask one question of many platforms in one call. Send it with dry_run=1 first. A dry run creates nothing, costs nothing and returns the estimate.

Preferred call

GET /v1/search/everywhere. Pass query. Narrow it with period and sources.

Simple example

One call, no error handling.

socialcrawl.mts
const url = new URL("https://www.socialcrawl.dev/v1/search/everywhere");
url.searchParams.set("query", "kanye west");
url.searchParams.set("dry_run", "1");
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
});
const body = await res.json();
console.log(body.data);

Complex example

Adds more params. A failed call raises an error that names its error.type.

socialcrawl.mts
// Send one request. Throw with error.type and error.doc_url when success is false.
async function send(url: URL) {
  const res = await fetch(url, {
    headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
  });
  const body = await res.json();
  if (!body.success) {
    const { type, message, doc_url } = body.error;
    throw new Error(`${type}: ${message} (${doc_url})`);
  }
  return body;
}

const url = new URL("https://www.socialcrawl.dev/v1/search/everywhere");
url.searchParams.set("query", "kanye west");
url.searchParams.set("period", "last_month");
url.searchParams.set("sources", "reddit,youtube");
url.searchParams.set("dry_run", "1");
const answer = await send(url);
console.log(answer.data.estimate, answer.credits_used);

Parameters

NameWhat it does
queryThe phrase to search on every platform, 1 to 512 characters.
periodA window by name: Nd for the last N days, yesterday, last_week, last_month, this_year and more.
sourcesOptional CSV allowlist of sources (mutually exclusive with exclude).
dry_runSend 1 to price the search without running it. Free.

Price a call before you send it

Why use it

Use it to learn what a call costs before you make it. You name the endpoint and its params. The answer is the price. The call is free.

Preferred call

GET /v1/utility/estimate. Pass id as platform/resource, and params as a query string.

Simple example

One call, no error handling.

socialcrawl.mts
const url = new URL("https://www.socialcrawl.dev/v1/utility/estimate");
url.searchParams.set("id", "tiktok/post/comments");
url.searchParams.set("params", "url=https://www.tiktok.com/@stoolpresidente/video/7623818255903329566&label=spam");
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
});
const body = await res.json();
console.log(body.data);

Complex example

Adds more params. A failed call raises an error that names its error.type.

socialcrawl.mts
// Send one request. Throw with error.type and error.doc_url when success is false.
async function send(url: URL) {
  const res = await fetch(url, {
    headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY! },
  });
  const body = await res.json();
  if (!body.success) {
    const { type, message, doc_url } = body.error;
    throw new Error(`${type}: ${message} (${doc_url})`);
  }
  return body;
}

const url = new URL("https://www.socialcrawl.dev/v1/utility/estimate");
url.searchParams.set("id", "tiktok/profile/videos");
url.searchParams.set("params", "handle=charlidamelio");
url.searchParams.set("items", "100");
const answer = await send(url);
console.log(answer.data, answer.credits_used);

Parameters

NameWhat it does
idThe endpoint to price, as platform/resource (tiktok/post/comments) or its /v1 path, optionally with its query string.
paramsThe endpoint's own params, as a URL-encoded query string (url=...&label=spam) or a JSON object.
itemsRows you want.