SocialCrawl

Use SocialCrawl with v0

Pull social media data into v0 without writing a server.

You can build a Next.js app in v0 that shows SocialCrawl data. A route handler on the server makes the call, so the key never reaches the browser. Setup takes three steps: add the variable, send the prompt, test the app.

Before you start

Create an API key in the dashboard under API Keys. Add it as an environment variable named SOCIALCRAWL_API_KEY. Do not give it the NEXT_PUBLIC_ prefix, because Next.js sends only variables with that prefix to the browser. Never paste the key into a prompt. Prove the key with a call that costs nothing:

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

Paste a prompt that names the endpoint and the rule about the key:

Prompt
Add a page that shows the 10 latest videos of a TikTok account. Create a
route handler that calls https://www.socialcrawl.dev/v1/tiktok/profile/videos?handle=mrbeast
with the query parameter handle (default: mrbeast). Send the key in the
x-api-key header from process.env.SOCIALCRAWL_API_KEY. Never call
SocialCrawl from client code. Show the rows in data.items, and pass the
response status through to the page.

Change the endpoint and the field list to build another view. Browse the platform directory to find endpoints.

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.

Response (trimmed)
{
  "success": true,
  "data": { "items": [{ "id": "7654638524729216287" }] },
  "pagination": { "next_cursor": "sc.eyJ2Ijoy…", "has_more": true },
  "credits_used": 1,
  "credits_remaining": 99
}

Ask v0 for a Load more button that sends next_cursor back as cursor, and hides itself when has_more is false. See Pagination.

When it stops

The route handler should forward the status, so the page can tell a refused call from a broken one.

When credits run out, the answer is a 402 with error.type set to INSUFFICIENT_CREDITS. Ask for a card on the page that shows 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 401 means the variable is missing or wrong.

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.

On this page