InsightSocial API

Using an AI agent

Point Claude, ChatGPT, Cursor or any coding agent at the InsightSocial API with one paste-in prompt and the free endpoint catalogue, so it reads the real paths, parameters and prices instead of guessing.

You do not have to read the rest of these docs before you start. Paste the prompt below into your agent and it will read the free endpoint catalogue, check your key and make the first calls for you. Everything happens over plain HTTPS: one base URL, one header, one JSON envelope. There is nothing to install.

Why the catalogue matters

GET https://api.insightsocial.app/v1/endpoints is public and free, and it needs no key. It lists every endpoint with its description, every parameter (name, type, whether it is required, allowed values, an example) and its price in credits. An agent that reads it before planning a call never invents a path or a parameter, and it can tell you what a job will cost before it spends anything.

cURL
# Every endpoint on one platform
curl "https://api.insightsocial.app/v1/endpoints?platform=tiktok"
Response (one entry, trimmed)
{
  "path": "/v1/tiktok/profile",
  "method": "GET",
  "platform": "tiktok",
  "description": "Returns a TikTok account's public profile: display name, bio, follower count ...",
  "credits": 20,
  "paginates": false,
  "cache_ttl_seconds": 86400,
  "params": [
    { "name": "handle", "required": false, "in": "query", "type": "string",
      "example": "charlidamelio", "one_of_group": "handle|user_id" },
    { "name": "user_id", "required": false, "in": "query", "type": "string",
      "one_of_group": "handle|user_id" }
  ],
  "available": true
}

A few fields worth knowing:

FieldMeaning
creditsA number for a fixed price, or { "min", "max" } for a metered endpoint. A metered call holds max when it starts and is charged what it actually used.
params[].one_of_groupParameters in the same group are alternatives: send at least one of them.
paginatestrue when the endpoint returns a cursor for the next page.
cache_ttl_secondsHow long repeating the exact same call is free for you after you paid for it.
availableOnly call endpoints where this is true.

?platform= takes one of instagram, tiktok, facebook, linkedin, twitter, threads, youtube, reddit or pinterest. Leave it off to get all nine platforms at once.

Give it the docs as Markdown

Every page of these docs is also plain Markdown: add .md to its URL, for example https://www.insightsocial.app/docs/pagination.md. Two files cover the whole site:

  • https://www.insightsocial.app/docs/llms.txt lists every page, one line each.
  • https://www.insightsocial.app/docs/llms-full.txt is every page in one file.

Paste either into a chat, or let an agent that can fetch URLs read them itself.

Copy the prompt

Put your key in the environment first, so it never appears in the chat:

Terminal
export INSIGHTSOCIAL_API_KEY=isk_live_...

Then paste this into your agent:

Prompt
Set up the InsightSocial API in this project and make a first successful call.

Facts you can rely on:
- Base URL: https://api.insightsocial.app/v1
- Auth: send the header `x-api-key: $INSIGHTSOCIAL_API_KEY` on every request. Read the key from
  the environment. Never print it, put it in a URL, or commit it. Authorization: Bearer is refused.
- All data endpoints are GET with query parameters.
- Success responses look like: { success: true, platform, endpoint, data, pagination?,
  credits_used, credits_remaining, request_id, cached, idempotent_replay, charge_reason, free_call }.
  List responses add pagination { next_cursor, has_more }.
- Error responses look like: { success: false, error: { type, message }, request_id,
  credits_used, credits_remaining }.
- Prices are per endpoint, in credits. Failed calls, empty results and dry_run=1 calls are
  never charged. Repeating the exact same call within the endpoint's cache_ttl_seconds is free.

Before writing any call, read the catalogue instead of guessing paths or parameters.
It is free and needs no key:
  GET https://api.insightsocial.app/v1/endpoints
  GET https://api.insightsocial.app/v1/endpoints?platform=<platform>
Use only endpoints where available is true, only parameters listed for that endpoint,
and tell me the price (credits, or min-max for metered) before any call over 100 credits.

Then, in order:
1. Verify the key with GET https://api.insightsocial.app/v1/credits (free) and print
   credits_remaining.
2. Call GET https://api.insightsocial.app/v1/tiktok/profile?handle=khaby.lame and print
   data.author.followers and credits_used.
3. Read the same kind of account on instagram/profile (handle=natgeo), youtube/channel
   (handle=mkbhd) and twitter/profile (handle=nasa). Print one line per platform.
4. Pick one list endpoint from the catalogue whose paginates is true, and read two pages by
   sending pagination.next_cursor back as ?cursor= while has_more is true. Send cursor values
   back unchanged.

Rules:
- Check `success` before using `data`. Branch on error.type, never on the message text.
- Retry only on HTTP 429, HTTP 503, IDEMPOTENCY_IN_PROGRESS and INTERNAL_ERROR. Wait for the
  Retry-After header when present, then back off with jitter. Never retry other 4xx errors.
- On INSUFFICIENT_CREDITS, stop and tell me. Do not retry.
- Stay under 60 requests per minute and 10 requests in flight.
- Stop and ask me before spending more than 1,000 credits in total.

The prompt pins down the three things an agent must not guess (the base URL, the header and the response shape), sends it to the catalogue before it writes a call, and gives it four concrete tasks that end with accounts read on four platforms. The whole exercise costs roughly 120 to 200 credits, and on a new account the 10 free calls cover most of it.

What the agent will do first

A good agent run starts the same way every time, and you can ask for these steps by name:

Read the catalogue. GET /v1/endpoints?platform=<platform> to find the endpoint and its parameters. Free, no key.

Check the key. GET /v1/credits confirms the key works and returns your balance, the monthly allowance, pack credits and your remaining free calls. Free.

Run a single paid request, then swap the platform segment of the path and run it again to see how another network answers.

cURL
curl "https://api.insightsocial.app/v1/credits" \
  -H "x-api-key: $INSIGHTSOCIAL_API_KEY"

Wiring the API into your own agent

When you build the agent yourself, one generic HTTP tool is enough: the model picks the path and parameters from the catalogue, and your tool makes the call. Keep the key in your code, not in the model's context.

Python
import os
import requests

KEY = os.environ["INSIGHTSOCIAL_API_KEY"]
BASE = "https://api.insightsocial.app/v1"

# Give the model this catalogue once, as reference text or a second tool.
CATALOGUE = requests.get(f"{BASE}/endpoints", timeout=30).json()

def insightsocial_get(path: str, params: dict) -> dict:
    """Tool: call one InsightSocial endpoint, e.g. path='tiktok/profile'."""
    res = requests.get(f"{BASE}/{path.removeprefix('/v1/').lstrip('/')}",
                       params=params, headers={"x-api-key": KEY}, timeout=120)
    body = res.json()
    if not body["success"]:
        # Hand the model a short instruction, not a raw error envelope.
        retry = res.headers.get("Retry-After")
        return {"error": body["error"]["type"], "message": body["error"]["message"],
                "retry_after_seconds": retry}
    return {"data": body["data"], "pagination": body.get("pagination"),
            "credits_used": body["credits_used"],
            "credits_remaining": body["credits_remaining"]}

Describe the tool to the model with two parameters, path (string, for example tiktok/profile) and params (object of query parameters). This works with Claude tool use, OpenAI function calling or any agent framework, because it is only an HTTP request.

Three habits keep an agent loop cheap and correct:

  • Return a short error, not the envelope. A model given a raw success: false body tends to reason around it. Hand it the error.type and let your code decide whether to retry.
  • Watch the budget. Every response carries credits_used and credits_remaining. Stop the loop on a budget you set, and cap the number of tool steps.
  • Price before you call. For metered endpoints the catalogue's max is what the call holds up front. On endpoints that take dry_run, dry_run=1 returns an estimate in data.estimate and is never charged.

Troubleshooting

The agent gets MISSING_API_KEY. It is almost certainly putting the key in Authorization: Bearer. That header is ignored: the API looks for the key in x-api-key and nowhere else, so a Bearer-only request arrives with no key at all. INVALID_API_KEY is different: the x-api-key header is present but its value is wrong, such as a token that does not start with isk_ or a key that does not exist.

It invents parameters. Unknown parameters are passed along and may be rejected with a 400. Errors are never charged, but they waste a round trip. Tell the agent to read GET /v1/endpoints?platform=<platform> first and use only the listed params.

It hits RATE_LIMITED or CONCURRENCY_LIMIT. Each key allows 60 requests per minute and 10 in flight. Have the agent honour Retry-After and run fewer calls in parallel. See Rate limits.

It gets INSUFFICIENT_CREDITS on a call that should be cheap. A metered call holds its ceiling before it runs, so the balance has to cover max, not the final charge. Top up at insightsocial.app/pricing. API credits share one balance with your InsightSocial export credits, and they are non-refundable. Calls that fail or return nothing are simply never charged.

It keeps paying for the same data. Repeating the exact same call inside its cache_ttl_seconds is free and returns charge_reason: "owned". Make sure the agent is not adding fresh=1 or Cache-Control: no-cache, which force a new, charged fetch.

Next steps

On this page