# Replit (/docs/integrations/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: ```bash title="Check the key (0 credits)" 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`: ```javascript title="server.js" 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. ```json title="Response (trimmed)" { "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](/docs/pagination.md). ## 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](/docs/errors.md). ## What a run costs It depends on the endpoint, and some endpoints are priced by what they return. [Endpoint pricing](/docs/endpoint-pricing.md) lists each one, and [Credits](/docs/credits.md) 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. - [Errors](/docs/errors.md): Every error code, with the fix and whether to retry. - [Authentication](/docs/authentication.md): Where the key goes and where it must never go. - [Endpoint pricing](/docs/endpoint-pricing.md): What each endpoint costs before visitors trigger it.