Use SocialCrawl with Replit
Pull social media data into Replit without writing a server.
You can build an app on Replit that shows SocialCrawl data. The key lives in the Secrets tool, and the server code reads it, so the browser never sees it. Setup takes three steps: add the secret, write or prompt the code, run the app.
Before you start
Create an API key in the dashboard under API Keys. Open the Secrets tool, select New secret, and add SOCIALCRAWL_API_KEY with your key. Replit encrypts it and exposes it to your app as an environment variable. Never write the key into a file. Prove the key with a call that costs nothing:
curl "https://www.socialcrawl.dev/v1/credits/balance" \
-H "x-api-key: sc_your_key_here"A reply with "success": true and your balance in data.balance means the key works.
Connect
Read the secret in server code with process.env.SOCIALCRAWL_API_KEY:
const res = await fetch(
"https://www.socialcrawl.dev/v1/tiktok/profile/videos?handle=mrbeast",
{ headers: { "x-api-key": process.env.SOCIALCRAWL_API_KEY } }
);
const body = await res.json();Secrets in the development pane work only in the editor. For a published app, add the same key to the deployment secrets, which Replit keeps separate.
Read the answer
Every response has the same shape. Branch on success. A list puts its rows in data.items, and pagination.next_cursor is the token for the next page.
{
"success": true,
"data": { "items": [{ "id": "7654638524729216287" }] },
"pagination": { "next_cursor": "sc.eyJ2Ijoy…", "has_more": true },
"credits_used": 1,
"credits_remaining": 99
}To read the next page, send next_cursor back as the cursor query parameter, and stop when has_more is false. See Pagination.
When it stops
Have your route pass the status and the body to the page, and show error.message when success is false.
When credits run out, the answer is a 402 with error.type set to INSUFFICIENT_CREDITS. Show error.message and a link to error.details.checkout_url, which opens checkout. When the link is absent, error.details.top_up_url opens the billing page. A missing secret answers 401, not 402, so check the secret first when every call fails.
Never retry a 402, because it fails until credits are added. Retry a 429 after the seconds in the Retry-After header, and a 502, 503 or 504 after a short backoff. See Errors.
What a run costs
It depends on the endpoint, and some endpoints are priced by what they return. Endpoint pricing lists each one, and Credits explains cache hits and refunds. Every visitor who opens the page triggers a call on your account unless you cache it. GET /v1/utility/estimate quotes a call for 0 credits.
