SocialCrawl

Docs for agents

Python source of truth

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

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

Install

You need Python 3.10 or later and the requests package.

Terminal
pip install requests

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.py
import os

import requests

res = requests.get(
    "https://www.socialcrawl.dev/v1/credits/balance",
    headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
    timeout=60,
)
print(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.py
import os

import requests

res = requests.get(
    "https://www.socialcrawl.dev/v1/tiktok/profile",
    headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
    params={"handle": "charlidamelio"},
    timeout=60,
)
print(res.json()["data"])

Complex example

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

socialcrawl.py
import os

import requests

API = "https://www.socialcrawl.dev"


def call(path, params):
    """Send one request. Raise with error.type and error.doc_url when success is false."""
    res = requests.get(
        API + path,
        headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
        params=params,
        timeout=60,
    )
    body = res.json()
    if not body["success"]:
        error = body["error"]
        raise RuntimeError(f"{error['type']}: {error['message']} ({error.get('doc_url')})")
    return body

answer = call("/v1/tiktok/profile", {"handle": "charlidamelio", "counts": "web"})
print(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.py
import os

import requests

res = requests.get(
    "https://www.socialcrawl.dev/v1/tiktok/profile/videos",
    headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
    params={"since": "2026-09-01", "handle": "charlidamelio"},
    timeout=60,
)
body = res.json()
print(len(body["data"]["items"]), 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.py
import os

import requests

API = "https://www.socialcrawl.dev"


def call(path, params):
    """Send one request. Raise with error.type and error.doc_url when success is false."""
    res = requests.get(
        API + path,
        headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
        params=params,
        timeout=60,
    )
    body = res.json()
    if not body["success"]:
        error = body["error"]
        raise RuntimeError(f"{error['type']}: {error['message']} ({error.get('doc_url')})")
    return body

params = {"handle": "charlidamelio"}
for page in (1, 2):
    answer = call("/v1/tiktok/profile/videos", params)
    pagination = answer["pagination"]
    print(page, len(answer["data"]["items"]), pagination["next_cursor"])
    if not pagination["has_more"]:
        break
    params["cursor"] = pagination["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.py
import os

import requests

res = requests.get(
    "https://www.socialcrawl.dev/v1/search/everywhere",
    headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
    params={"query": "kanye west", "dry_run": "1"},
    timeout=60,
)
print(res.json()["data"])

Complex example

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

socialcrawl.py
import os

import requests

API = "https://www.socialcrawl.dev"


def call(path, params):
    """Send one request. Raise with error.type and error.doc_url when success is false."""
    res = requests.get(
        API + path,
        headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
        params=params,
        timeout=60,
    )
    body = res.json()
    if not body["success"]:
        error = body["error"]
        raise RuntimeError(f"{error['type']}: {error['message']} ({error.get('doc_url')})")
    return body

answer = call("/v1/search/everywhere", {"query": "kanye west", "period": "last_month", "sources": "reddit,youtube", "dry_run": "1"})
print(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.py
import os

import requests

res = requests.get(
    "https://www.socialcrawl.dev/v1/utility/estimate",
    headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
    params={"id": "tiktok/post/comments", "params": "url=https://www.tiktok.com/@stoolpresidente/video/7623818255903329566&label=spam"},
    timeout=60,
)
print(res.json()["data"])

Complex example

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

socialcrawl.py
import os

import requests

API = "https://www.socialcrawl.dev"


def call(path, params):
    """Send one request. Raise with error.type and error.doc_url when success is false."""
    res = requests.get(
        API + path,
        headers={"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]},
        params=params,
        timeout=60,
    )
    body = res.json()
    if not body["success"]:
        error = body["error"]
        raise RuntimeError(f"{error['type']}: {error['message']} ({error.get('doc_url')})")
    return body

answer = call("/v1/utility/estimate", {"id": "tiktok/profile/videos", "params": "handle=charlidamelio", "items": "100"})
print(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.