socialcrawl-mcp 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +94 -112
  2. package/dist/client.d.ts +2 -0
  3. package/dist/client.js +4 -0
  4. package/dist/constants.d.ts +10 -1
  5. package/dist/constants.js +10 -1
  6. package/dist/cost-guard.d.ts +8 -1
  7. package/dist/cost-guard.js +21 -9
  8. package/dist/data/docs-handwritten.js +4 -3
  9. package/dist/data/docs.js +1 -1
  10. package/dist/data/endpoints.js +65 -33
  11. package/dist/data/examples.js +1 -1
  12. package/dist/data/guide.d.ts +1 -1
  13. package/dist/data/guide.js +1 -1
  14. package/dist/data/outputs.js +218 -217
  15. package/dist/data/platforms.js +1 -1
  16. package/dist/data/recipes.js +1 -1
  17. package/dist/data/registry-meta.d.ts +4 -4
  18. package/dist/data/registry-meta.js +4 -4
  19. package/dist/endpoint-resolve.d.ts +10 -0
  20. package/dist/endpoint-resolve.js +34 -0
  21. package/dist/format/shape.d.ts +6 -0
  22. package/dist/format/shape.js +64 -0
  23. package/dist/freshness.d.ts +27 -4
  24. package/dist/freshness.js +42 -19
  25. package/dist/oauth/jwt-verifier.js +7 -0
  26. package/dist/oauth/resource-server.d.ts +3 -1
  27. package/dist/oauth/resource-server.js +12 -2
  28. package/dist/oauth/scopes.d.ts +13 -0
  29. package/dist/oauth/scopes.js +33 -0
  30. package/dist/result.d.ts +2 -0
  31. package/dist/result.js +8 -0
  32. package/dist/schemas/normalize.d.ts +27 -0
  33. package/dist/schemas/normalize.js +189 -0
  34. package/dist/schemas/outputs.d.ts +51 -31
  35. package/dist/schemas/outputs.js +10 -4
  36. package/dist/schemas/tools.d.ts +43 -8
  37. package/dist/schemas/tools.js +20 -7
  38. package/dist/server.js +17 -12
  39. package/dist/tools/cohorts.d.ts +3 -1
  40. package/dist/tools/cohorts.js +11 -10
  41. package/dist/tools/collect.d.ts +7 -3
  42. package/dist/tools/collect.js +110 -9
  43. package/dist/tools/discover.js +22 -27
  44. package/dist/tools/endpoint.js +9 -5
  45. package/dist/tools/estimate.js +53 -9
  46. package/dist/tools/find.d.ts +4 -0
  47. package/dist/tools/find.js +276 -9
  48. package/dist/tools/manage.d.ts +4 -0
  49. package/dist/tools/manage.js +106 -4
  50. package/dist/tools/monitors.d.ts +8 -1
  51. package/dist/tools/monitors.js +17 -12
  52. package/dist/tools/pricing.d.ts +1 -5
  53. package/dist/tools/pricing.js +17 -0
  54. package/dist/tools/request.d.ts +2 -11
  55. package/dist/tools/request.js +123 -74
  56. package/dist/tools/web.d.ts +3 -1
  57. package/dist/tools/web.js +4 -3
  58. package/dist/types.d.ts +9 -4
  59. package/package.json +2 -2
@@ -1,3 +1,3 @@
1
1
  /** The skill's SKILL.md body and errors reference. Generated by scripts/generate-data.ts (T28) - do not hand-edit. */
2
- export declare const GUIDE = "# SocialCrawl API\n\nOne API key and one response envelope for social, commerce, and research data. Lists are `{ items, next_cursor?, total? }`; add `?format=raw` to skip the transform pipeline. Every file below lives in `references/`; open only the one the task needs.\n\n## API Key\n\nResolve the API key only when a live API call is needed. Documentation, capability, pricing, and code-generation questions do not need a key.\n\nCheck these sources in order without displaying their contents:\n\n1. **Environment variable:** use `SOCIALCRAWL_API_KEY` when it starts with `sc_` and is not an example placeholder.\n2. **Config file:** if the environment variable is absent, load `~/.config/socialcrawl/api_key` into `SOCIALCRAWL_API_KEY` in the current process. On POSIX shells, use `SOCIALCRAWL_API_KEY=\"$(<\"$HOME/.config/socialcrawl/api_key\")\"; export SOCIALCRAWL_API_KEY`. On PowerShell, use `$env:SOCIALCRAWL_API_KEY = (Get-Content -LiteralPath \"$HOME/.config/socialcrawl/api_key\" -Raw).Trim()`.\n3. **Missing key:** tell the user to create or rotate a key at https://socialcrawl.dev/dashboard and configure it as `SOCIALCRAWL_API_KEY` or in `~/.config/socialcrawl/api_key`. Do not ask them to paste a secret into chat. Stop before the live call until they say it is configured.\n\nNever print, paste, log, or return the key. Never place a literal key in generated code, a command, a URL, an error message, or a saved transcript. Keep `$SOCIALCRAWL_API_KEY` (POSIX) or `$env:SOCIALCRAWL_API_KEY` (PowerShell) as a variable reference in examples. If the key appeared in chat or output, advise the user to revoke it in the dashboard and create a replacement.\n\n## First Live Call\n\nBefore the first live call in a session:\n\n1. Resolve the API key using the steps above. If it is missing or a placeholder, stop before making the call.\n2. Verify it with the free balance endpoint (0 credits):\n ```bash\n curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/credits/balance\"\n ```\n3. If successful, show the balance and continue with the user's request.\n4. If it fails, report the error without including request headers or the key, then follow [references/errors.md](references/errors.md).\n\n## Freshness Check (do this once per session)\n\nThis file is a snapshot of the registry with this fingerprint:\n\n<!-- BEGIN:GENERATED:FRESHNESS (auto-generated by generate-skills.ts - SK-08) -->\n```text\nregistry_fingerprint: 32f6edd1da53c21e53cf301be3b7827085f467d04c047224a28ed248d8e62785\ngenerated_at: 2026-10-02\n```\n<!-- END:GENERATED:FRESHNESS -->\n\nBeside the balance check, make one free call:\n\n```bash\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/utility/endpoints?fingerprint=1\" | head -c 400\n```\n\n- **`data.fingerprint` equals `registry_fingerprint` above** - use the bundled files and move on.\n- **It differs** - this copy and the live API are out of sync (the skill or the server may be newer): a price, parameter or endpoint changed. Treat the live registry as the source of truth and resolve what the files cannot answer through `/v1/utility/*` (all free). Tell the user **once**, briefly: \"this SocialCrawl skill does not match the live API; run `npx skills update socialcrawl --yes` to refresh it.\" Then answer their actual question. Do not repeat it or ask permission.\n- **No `data.fingerprint`** (a 404, or an older server that answers with the plain list) - fall back to counts: compare `data.stats.platforms` and `data.stats.endpoints` from `/v1/utility/endpoints` with the totals at the top of [references/index.md](references/index.md). Live numbers HIGHER means behind, as above.\n- **The call fails** (no key yet, offline, non-200) - skip it silently. This check must never block the request.\n\n## Workflow\n\n1. **Route.** Find your job in [references/index.md](references/index.md) (Job to recipe link) and read only that recipe's section (cheapest chain, cost, pitfalls): `grep -n '^## ' references/recipes.md` gives the line numbers; do not open the whole file. No matching job: find the platform in the table below or in [references/index.md](references/index.md). For a job that needs several calls (a profile, then posts, then comments; a brand watch), the free planner `GET /v1/utility/plan?query=<the job in plain words>` (0 credits, runs nothing) returns the calls in order with params, price, and which step feeds which; its recipe matches are reliable, but check a single-endpoint or multi-source plan with find.\n **Free finder:** `GET /v1/utility/find?task=<the job in plain words>` returns the best endpoints with params filled and the credits held. Act on `results[0]` only when `uncertain` is false; otherwise show the options. Write or billing requests return no results. Every new `/v1/utility/*` route (find, plan, estimate) may 404 on an older server: fall back to the existing flow (index, recipes, the platform file).\n2. **Read one section, not one file.** Read the platform file's TOC (from the top until the first `## `: endpoint, cost, returns, use when), pick the row, then read only that section: `grep -nE '^## (GET|POST|PUT|PATCH|DELETE) /v1/<platform>/<resource> - ' references/<platform>.md`, and read from that line to the next `## `. The section carries the exact cost, cache TTL, pagination, every parameter, and the constraints checked before billing.\n3. **Estimate.** Build the exact request and apply the cost gate below (one line for a small flat call, the full preflight in [references/cost-gate.md](references/cost-gate.md) for anything metered or large). A heading's number can be a per-row or per-page unit, not the request total.\n4. **Call.** Resolve the key, then run the request exactly as the section shows it, keeping its HTTP method and body shape. If the user already asked to run this exact paid request, the cost disclosure is enough, except the Ask level: always ask (see the gate in the Cost rule); otherwise ask only before a paid call or wider scope they did not authorise.\n5. **Report.** Return the data, then `credits_used` and `credits_remaining`. For an async job report the hold at submission and the settled charge on completion.\n\n**Code requests:** read the section and cost-gate, write a snippet that reads `SOCIALCRAWL_API_KEY` from the environment with a comment stating the billing unit, and present it without running it.\n\n**Capability and pricing questions:** answer from the index and [references/pricing.md](references/pricing.md) (cost, tiers, packs, refunds, the free-endpoint list). Auth, envelope, pagination, labels, caching, idempotency: [references/api-overview.md](references/api-overview.md). The free `/v1/utility/*` calls answer from the live registry: `endpoints` (filter `?platform=`, `?search=`), `endpoint?id=tiktok/profile` (one endpoint, with measured field fill rates), `plan?query=`, `quickstart`.\n\n**Ambiguous platform:** if the user says \"get @nike's profile\" with no platform, ask which one.\n\n## Where to look\n\n| Need | Open |\n|------|------|\n| Any single platform (social, commerce, reviews and places, app stores, search/news/finance, research and dev, link-in-bio) | [index.md](references/index.md) lists every platform file with its endpoint count; open `references/<platform>.md` |\n| One call over many platforms: Prism composites, `search/multi`, `search/everywhere` | [prism.md](references/prism.md), [search.md](references/search.md) |\n| Scheduled re-runs with webhook delivery | [monitors.md](references/monitors.md) |\n| \"Which of MY list of accounts posted about X\" (Cohorts, not listening) | [cohorts.md](references/cohorts.md) |\n| Cost of a request or a whole paged walk | [cost-gate.md](references/cost-gate.md), [pricing.md](references/pricing.md) |\n| A failed call | [errors.md](references/errors.md) |\n\n> **Never answer \"not supported\" from this table alone.** It is only as new as this file, and a missing row is far more often a stale copy than a real gap. Before telling a user a platform, endpoint or capability does not exist, check the live registry - it is free:\n>\n> ```bash\n> curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n> \"https://www.socialcrawl.dev/v1/utility/endpoints?search=douyin\"\n> ```\n>\n> Each row carries `path`, `method`, `credits_label`, `required_params`, `one_of`, `optional_params`, `paginated` and `cache_ttl_seconds`: enough to make the call without this file. Only say it is unsupported when the search returns `total: 0`.\n\n**Comparing products across retailers:** Amazon, Walmart, Target, eBay and Home Depot share the canonical Product / Review / Seller schemas, so rows line up. Resolve each retailer's product id (ASIN, item id, TCIN, ...) with its own search, then fetch detail and reviews per retailer. `/v1/prism/product-reviews` is one composite over Amazon, Google Shopping and Trustpilot reviews only; for Walmart, Target or Home Depot call `<retailer>/reviews`.\n\n**Several platforms at once:** `/v1/search/multi` runs one query over several platforms' own search (each platform's page price, charged only for those that returned rows); `/v1/search/everywhere` (20 credits) plans, ranks, and clusters up to 17 sources; many profiles or post URLs go to `POST /v1/prism/profiles` / `POST /v1/prism/post-stats`, or the background job `POST /v1/prism/jobs`.\n\n## Making calls\n\nBase URL `https://www.socialcrawl.dev`. Most endpoints are GET with query parameters (URL-encode values):\n\n```\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n \"https://www.socialcrawl.dev/v1/{platform}/{resource}?{param}={value}\"\n```\n\n**Never assume the method.** Each endpoint section is headed by its real verb with a runnable curl. Batch reads, Prism jobs, web jobs, monitors, and cohorts use POST, PATCH, PUT, or DELETE with `content-type: application/json` (`web/parse` is multipart); the list, plus streaming (`Accept: text/event-stream`) and two-step endpoints that need an id from an earlier call, is in [api-overview.md](references/api-overview.md#non-get-routes-streaming-and-two-step-endpoints). Rate limits: 600 requests per minute and 50 concurrent per key; both return 429 with `Retry-After` and are never billed. Some endpoints are task-polled and take 10-45s: use a 60s timeout.\n\n## Reading a response\n\nDetails are in [api-overview.md](references/api-overview.md). Five rules before the first call:\n\n- **Placement.** `pagination` (`next_cursor`, `has_more`, `page_size`) and the optional `meta.hint` sit at the envelope root. `dropped`, `_warnings` and every page report (`labels`, `relevance`, `label_share`, `hydration`, `walk`, ...) sit inside `data`. Read `data._warnings`: an ignored parameter (`count was ignored; use limit (page size)`) or a handle that resolved to a different account (`resolved_to_different_handle`) is reported there, not as an error.\n- **Paging.** Send `pagination.next_cursor` back as `cursor` and stop on `has_more: false`, not on a short page or on `total`. A zero-match list is `200` with `items: []` at 0 credits.\n- **Default judgments are free.** Comment, post, review and keyword-search rows carry labels (`computed.labels`) and search rows a relevance score (`computed.relevance`) at no extra cost; `judgments=off` removes them. Opt-in presets (`label=spam|toxic|low_quality|quality|injection|mention`, `relevant_to=`) add **1 credit per 25 newly judged rows**. `relevance=filter` against the query is free.\n- **Spend controls.** Creator post lists take `stop_at_id` / `since` so a poll pays only for new pages (`pagination.stopped_at` says why it stopped). Keyword searches take `min_views`, `max_age_days`, `country` / `exclude_country`, `sort_rows=views`, `seen=<id>` (repeats refunded) and `max_pages` (1-5, **each page billed**).\n- **`meta.hint`** names one other call that does the job in fewer steps. Its message states the price when that call costs more; follow it only within what the user authorised.\n\n`include=` hydration joins rows to a sibling endpoint and is charged **per row on top of the page**, so never quote the plain heading cost for a hydrated call; the ceilings are in [cost-gate.md](references/cost-gate.md#row-hydration-include) and the traps in [api-overview.md](references/api-overview.md#row-hydration-include).\n\n## Cost rule\n\nCache hits, idempotent replays, every `/v1/utility/*` endpoint, and `/v1/credits/balance` cost 0 credits. Failed calls are refunded, and a request rejected for bad params, a page past the last page, or a rate limit never deducts. Metered endpoints hold an upfront ceiling and refund down to the work done, so the response `credits_used` is the real charge. Quote the total for the exact request, not the endpoint's base or unit cost. Scale the gate to the call:\n\n| Call | Gate |\n| --- | --- |\n| Flat price \u2264 5 credits, user asked for it | One line: `\u2248 N credits` |\n| Metered, multi-page, batch, monitor/cohort, or > 25 credits | Full preflight via `estimate.py` / `utility/estimate` |\n| Upfront hold (worst case) > 500 credits or over budget (the user's stated budget) | Ask before calling |\n\nAnything in between, or unsure of the price or params: quote first with the free `GET /v1/utility/estimate?id=<platform/resource>&<params>`. Any reply except a 404 means a current server (a 5xx or network failure is no reply: retry the estimate): use its quote, and `dry_run=1` is then free on any endpoint (validates, fetches nothing). A 404 or `ENDPOINT_NOT_FOUND` means an older server: do **not** send `dry_run=1` (it bills a normal call there, except the labelled dry run an endpoint documents); quote with `scripts/estimate.py` (offline, `assets/endpoints.json`) or the section's **Pricing** line. At every level, report `credits_used` after.\n\n**If the task needs a whole list, price the whole walk before the first page.** Paging to completion multiplies the page cost by the page count, and a heading only shows one page. `coverage=full` on `instagram/followers` and `instagram/following` is the extreme case: 10 credits a page, about 50 accounts a page, so a 2,600-account list is roughly 520 credits. Quote that total and get agreement before starting ([Multi-page walks](references/cost-gate.md#multi-page-walks-coveragefull)).\n\nErrors: classify before retrying with [references/errors.md](references/errors.md). Credits and balance: `GET /v1/credits/balance` (0 credits); the ledger is `GET /v1/credits/transactions?limit=50` (0 credits).";
2
+ export declare const GUIDE = "# SocialCrawl API\n\nOne API key and one response envelope for social, commerce, and research data. Lists are `{ items, next_cursor?, total? }`; add `?format=raw` to skip the transform pipeline. Every file below lives in `references/`; open only the one the task needs.\n\n## API Key\n\nResolve the API key only when a live API call is needed. Documentation, capability, pricing, and code-generation questions do not need a key.\n\nCheck these sources in order without displaying their contents:\n\n1. **Environment variable:** use `SOCIALCRAWL_API_KEY` when it starts with `sc_` and is not an example placeholder.\n2. **Config file:** if the environment variable is absent, load `~/.config/socialcrawl/api_key` into `SOCIALCRAWL_API_KEY` in the current process. On POSIX shells, use `SOCIALCRAWL_API_KEY=\"$(<\"$HOME/.config/socialcrawl/api_key\")\"; export SOCIALCRAWL_API_KEY`. On PowerShell, use `$env:SOCIALCRAWL_API_KEY = (Get-Content -LiteralPath \"$HOME/.config/socialcrawl/api_key\" -Raw).Trim()`.\n3. **Missing key:** tell the user to create or rotate a key at https://socialcrawl.dev/dashboard and configure it as `SOCIALCRAWL_API_KEY` or in `~/.config/socialcrawl/api_key`. Do not ask them to paste a secret into chat. Stop before the live call until they say it is configured.\n\nNever print, paste, log, or return the key. Never place a literal key in generated code, a command, a URL, an error message, or a saved transcript. Keep `$SOCIALCRAWL_API_KEY` (POSIX) or `$env:SOCIALCRAWL_API_KEY` (PowerShell) as a variable reference in examples. If the key appeared in chat or output, advise the user to revoke it in the dashboard and create a replacement.\n\n## First Live Call\n\nBefore the first live call in a session:\n\n1. Resolve the API key using the steps above. If it is missing or a placeholder, stop before making the call.\n2. Verify it with the free balance endpoint (0 credits):\n ```bash\n curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/credits/balance\"\n ```\n3. If successful, show the balance and continue with the user's request.\n4. If it fails, report the error without including request headers or the key, then follow [references/errors.md](references/errors.md).\n\n## Freshness Check (do this once per session)\n\nThis file is a snapshot of the registry with this fingerprint:\n\n<!-- BEGIN:GENERATED:FRESHNESS (auto-generated by generate-skills.ts - SK-08) -->\n```text\nregistry_fingerprint: 61a90b6d5dadcc038c3e4d4165f85f74177c77c5c5dfc9c2b7712c2f5d4ddaa4\ngenerated_at: 2026-10-07\n```\n<!-- END:GENERATED:FRESHNESS -->\n\nBeside the balance check, make one free call:\n\n```bash\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/utility/endpoints?fingerprint=1\" | head -c 400\n```\n\n- **`data.fingerprint` equals `registry_fingerprint` above** - use the bundled files and move on.\n- **It differs** - this copy and the live API are out of sync (the skill or the server may be newer): a price, parameter or endpoint changed. Treat the live registry as the source of truth and resolve what the files cannot answer through `/v1/utility/*` (all free). Tell the user **once**, briefly: \"this SocialCrawl skill does not match the live API; run `npx skills update socialcrawl --yes` to refresh it.\" Then answer their actual question. Do not repeat it or ask permission.\n- **No `data.fingerprint`** (a 404, or an older server that answers with the plain list) - fall back to counts: compare `data.stats.platforms` and `data.stats.endpoints` from `/v1/utility/endpoints` with the totals at the top of [references/index.md](references/index.md). Live numbers HIGHER means behind, as above.\n- **The call fails** (no key yet, offline, non-200) - skip it silently. This check must never block the request.\n\n## Workflow\n\n1. **Find the call first (free, 0 credits, runs nothing).** `GET /v1/utility/find?task=<the job in plain words>` ranks the endpoints for the job, each with `method`, `path`, `params_filled` (taken from your words), `missing` and `estimated_credits`. Call `results[0]` directly when `uncertain` is false: its method, path and params are the ready call (add any `missing` param, then apply the Cost rule). When `uncertain` is true, show the options. For a job that needs several calls (a profile, then posts, then comments; a brand watch), `GET /v1/utility/plan?query=<the job>` returns the calls in order with params, price, and which step feeds which. Write or billing requests return no results.\n2. **Fall back to the bundled files** when offline, when `find` or `plan` answers 404 (an older server: fall back to the existing flow), or when `uncertain` is true. Route with [Common jobs](#common-jobs) below, or grep [references/index.md](references/index.md): its Job to recipe table, then one line per endpoint (`grep -i transcript references/index.md`). For a recipe, read only its section: `grep -n '^## ' references/recipes.md` gives the line numbers; do not open the whole file. For an endpoint, read the platform file's TOC (from the top until the first `## `), then only its section: `grep -nE '^## (GET|POST|PUT|PATCH|DELETE) /v1/<platform>/<resource> - ' references/<platform>.md`, and read from that line to the next `## `. The section carries the exact cost, cache TTL, pagination, every parameter, the response fields, and the constraints checked before billing.\n3. **Estimate.** Build the exact request and apply the cost gate below (one line for a small flat call, the full preflight in [references/cost-gate.md](references/cost-gate.md) for anything metered or large). A heading's number can be a per-row or per-page unit, not the request total.\n4. **Call.** Resolve the key, then run the request exactly as the section shows it, keeping its HTTP method and body shape. If the user already asked to run this exact paid request, the cost disclosure is enough, except the Ask level: always ask (see the gate in the Cost rule); otherwise ask only before a paid call or wider scope they did not authorise.\n5. **Report.** Return the data, then `credits_used` and `credits_remaining`. For an async job report the hold at submission and the settled charge on completion.\n\n## Common jobs\n\nThe first call for the asks agents meet most, generated from the registry recipes (`{x}` is yours to fill). `find` gives the same answer with your values filled in.\n\n<!-- BEGIN:GENERATED:COMMON_JOBS (auto-generated by generate-skills.ts from registry recipes) -->\n| Job | First call | Then |\n|-----|------------|------|\n| Comments on a post to CSV | `GET /v1/tiktok/post/comments?url={url}&sort=recent&scan_pages=3` | `paginate.py` piped to `to_csv.py --archetype Comment`; any platform's `<platform>/post/comments`; [recipe](references/recipes.md#export-the-latest-n-comments-on-a-tiktok-video) |\n| Creators by niche, followers or country | `GET /v1/search/creators?query={niche}&sources=tiktok,instagram&min_followers={min_followers}` | `search/creators` has no country filter; [recipe](references/recipes.md#find-creators-in-a-niche); one country: [recipe](references/recipes.md#instagram-creators-from-one-country-about-a-topic); one country on a small budget: [recipe](references/recipes.md#instagram-creators-from-one-country-on-a-small-budget) |\n| A product's reviews across retailers | `GET /v1/prism/product-reviews?query={product}` | covers Amazon, Google Shopping and Trustpilot reviews; Walmart, Target, Home Depot: `<retailer>/reviews`; [recipe](references/recipes.md#one-report-on-a-products-reviews-across-marketplaces) |\n| Stock price and news | `GET /v1/finance/ticker-search?keyword={company}` | then `finance/quote` (`quote.price.current`) and `finance/news`; [recipe](references/recipes.md#a-stocks-current-price-and-latest-headlines) |\n| YouTube transcript | `GET /v1/youtube/video/transcript?url={url}` | [recipe](references/recipes.md#transcribe-a-video) |\n| Alert on new posts or changes | `POST /v1/monitors` (body `recipe: instagram/profile/posts`) | only when `GET /v1/utility/estimate?id=monitors` returns 200, send `?dry_run=1` first to validate and price without creating; otherwise describe the request and create nothing until the user agrees; a page: `web/monitors`; [recipe](references/recipes.md#track-a-creators-new-posts-every-day) |\n| Stats for a list of post URLs | `POST /v1/prism/post-stats` (JSON body `urls`) | a file of URLs: `batch.py --urls`; [recipe](references/recipes.md#engagement-stats-for-a-list-of-post-urls) |\n| Korean / Naver search | `GET /v1/naver/brief?query={keyword}&corpora=news,blog,cafearticle` | one corpus: `naver/blog/search`, `naver/news/search`; [recipe](references/recipes.md#what-korean-consumers-say-about-a-product-and-search-interest) |\n| Profile lookup | `GET /v1/tiktok/profile?handle={handle}` | any `<platform>/profile`; many handles: `prism/profiles`; [recipe](references/recipes.md#a-creators-profile-recent-posts-and-the-comments-on-them) |\n| Scrape a web page | `GET /v1/web/scrape?url={url}` | structured fields: `web/extract`; a whole site: `web/crawl` |\n| Brand mentions across the web | `GET /v1/prism/brand-mentions?keyword={brand}&date_from={start_date}&include=digest` | [recipe](references/recipes.md#watch-what-the-web-says-about-a-brand) |\n| One topic on several platforms | `GET /v1/search/multi?query={topic}&platforms=tiktok,instagram,youtube&relevance=filter` | [recipe](references/recipes.md#search-a-topic-on-several-platforms-at-once) |\n<!-- END:GENERATED:COMMON_JOBS -->\n\n## Helpers\n\nBundled scripts in `scripts/` (Python 3). They read the key from `SOCIALCRAWL_API_KEY` or `~/.config/socialcrawl/api_key` and never print it; `--help` on each gives the rest.\n\n```bash\npython3 scripts/sc.py tiktok/profile handle=nike # one call; JSON to stdout, credits_used to stderr\npython3 scripts/paginate.py tiktok/post/comments --items 500 --max-credits 20 url=<post_url> > rows.jsonl # page to N rows within a budget\npython3 scripts/to_csv.py --archetype Comment --in rows.jsonl --out comments.csv # rows to CSV with stable columns\npython3 scripts/batch.py --urls links.txt > stats.jsonl # stats for a file of post URLs (prism/post-stats, or one prism/jobs job past 500)\npython3 scripts/estimate.py tiktok/post/comments --items 500 --offline url=<post_url> # quote offline from assets/endpoints.json\n```\n\n**Code requests:** read the section and cost-gate, write a snippet that reads `SOCIALCRAWL_API_KEY` from the environment with a comment stating the billing unit, and present it without running it.\n\n**Capability and pricing questions:** answer from the index and [references/pricing.md](references/pricing.md) (cost, tiers, packs, refunds, the free-endpoint list). Auth, envelope, pagination, labels, caching, idempotency: [references/api-overview.md](references/api-overview.md). The free `/v1/utility/*` calls answer from the live registry: `endpoints` (filter `?platform=`, `?search=`), `endpoint?id=tiktok/profile` (one endpoint, with measured field fill rates), `plan?query=`, `quickstart`.\n\n**Ambiguous platform:** if the user says \"get @nike's profile\" with no platform, ask which one.\n\n## Where to look\n\n| Need | Open |\n|------|------|\n| Any single platform (social, commerce, reviews and places, app stores, search/news/finance, research and dev, link-in-bio) | [index.md](references/index.md) lists every platform file with its endpoint count; open `references/<platform>.md` |\n| One call over many platforms: Prism composites, `search/multi`, `search/everywhere` | [prism.md](references/prism.md), [search.md](references/search.md) |\n| Scheduled re-runs with webhook delivery | [monitors.md](references/monitors.md) |\n| \"Which of MY list of accounts posted about X\" (Cohorts, not listening) | [cohorts.md](references/cohorts.md) |\n| Cost of a request or a whole paged walk | [cost-gate.md](references/cost-gate.md), [pricing.md](references/pricing.md) |\n| A failed call | [errors.md](references/errors.md) |\n\n> **Never answer \"not supported\" from this table alone.** It is only as new as this file, and a missing row is far more often a stale copy than a real gap. Before telling a user a platform, endpoint or capability does not exist, check the live registry - it is free:\n>\n> ```bash\n> curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n> \"https://www.socialcrawl.dev/v1/utility/endpoints?search=douyin\"\n> ```\n>\n> Each row carries `path`, `method`, `credits_label`, `required_params`, `one_of`, `optional_params`, `paginated` and `cache_ttl_seconds`: enough to make the call without this file. Only say it is unsupported when the search returns `total: 0`.\n\n**Comparing products across retailers:** Amazon, Walmart, Target, eBay and Home Depot share the canonical Product / Review / Seller schemas, so rows line up. Resolve each retailer's product id (ASIN, item id, TCIN, ...) with its own search, then fetch detail and reviews per retailer. `/v1/prism/product-reviews` is one composite over Amazon, Google Shopping and Trustpilot reviews only; for Walmart, Target or Home Depot call `<retailer>/reviews`.\n\n**Several platforms at once:** `/v1/search/multi` runs one query over several platforms' own search (each platform's page price, charged only for those that returned rows); `/v1/search/everywhere` (20 credits) plans, ranks, and clusters up to 17 sources; many profiles or post URLs go to `POST /v1/prism/profiles` / `POST /v1/prism/post-stats`, or the background job `POST /v1/prism/jobs`.\n\n## Making calls\n\nBase URL `https://www.socialcrawl.dev`. Most endpoints are GET with query parameters (URL-encode values):\n\n```\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n \"https://www.socialcrawl.dev/v1/{platform}/{resource}?{param}={value}\"\n```\n\n**Never assume the method.** Each endpoint section is headed by its real verb with a runnable curl. Batch reads, Prism jobs, web jobs, monitors, and cohorts use POST, PATCH, PUT, or DELETE with `content-type: application/json` (`web/parse` is multipart); the list, plus streaming (`Accept: text/event-stream`) and two-step endpoints that need an id from an earlier call, is in [api-overview.md](references/api-overview.md#non-get-routes-streaming-and-two-step-endpoints). Rate limits: 600 requests per minute and 50 concurrent per key; both return 429 with `Retry-After` and are never billed. Some endpoints are task-polled and take 10-45s: use a 60s timeout.\n\n## Reading a response\n\nDetails are in [api-overview.md](references/api-overview.md). Five rules before the first call:\n\n- **Placement.** `pagination` (`next_cursor`, `has_more`, `page_size`) and the optional `meta.hint` sit at the envelope root. `dropped`, `_warnings` and every page report (`labels`, `relevance`, `label_share`, `hydration`, `walk`, ...) sit inside `data`. Read `data._warnings`: an ignored parameter (`count was ignored; use limit (page size)`) or a handle that resolved to a different account (`resolved_to_different_handle`) is reported there, not as an error.\n- **Paging.** Send `pagination.next_cursor` back as `cursor` and stop on `has_more: false`, not on a short page or on `total`. A zero-match list is `200` with `items: []` at 0 credits.\n- **Default judgments are free.** Comment, post, review and keyword-search rows carry labels (`computed.labels`) and search rows a relevance score (`computed.relevance`) at no extra cost; `judgments=off` removes them. Opt-in presets (`label=spam|toxic|low_quality|quality|injection|mention`, `relevant_to=`) add **1 credit per 25 newly judged rows**. `relevance=filter` against the query is free.\n- **Spend controls.** Creator post lists take `stop_at_id` / `since` so a poll pays only for new pages (`pagination.stopped_at` says why it stopped). Keyword searches take `min_views`, `max_age_days`, `country` / `exclude_country`, `sort_rows=views`, `seen=<id>` (repeats refunded) and `max_pages` (1-5, **each page billed**).\n- **`meta.hint`** names one other call that does the job in fewer steps. Its message states the price when that call costs more; follow it only within what the user authorised.\n\n`include=` hydration joins rows to a sibling endpoint and is charged **per row on top of the page**, so never quote the plain heading cost for a hydrated call; the ceilings are in [cost-gate.md](references/cost-gate.md#row-hydration-include) and the traps in [api-overview.md](references/api-overview.md#row-hydration-include).\n\n## Cost rule\n\nCache hits, idempotent replays, every `/v1/utility/*` endpoint, and `/v1/credits/balance` cost 0 credits. Failed calls are refunded, and a request rejected for bad params, a page past the last page, or a rate limit never deducts. Metered endpoints hold an upfront ceiling and refund down to the work done, so the response `credits_used` is the real charge. Quote the total for the exact request, not the endpoint's base or unit cost. Scale the gate to the call:\n\n| Call | Gate |\n| --- | --- |\n| Flat price \u2264 5 credits, user asked for it | One line: `\u2248 N credits` |\n| Metered, multi-page, batch, monitor/cohort, or > 25 credits | Full preflight via `estimate.py` / `utility/estimate` |\n| Upfront hold (worst case) > 500 credits or over budget (the user's stated budget) | Ask before calling |\n\nAnything in between, or unsure of the price or params: quote first with the free `GET /v1/utility/estimate?id=<platform/resource>&<params>`. Any reply except a 404 means a current server (a 5xx or network failure is no reply: retry the estimate): use its quote, and `dry_run=1` is then free on any endpoint (validates, fetches nothing). A 404 or `ENDPOINT_NOT_FOUND` means an older server: do **not** send `dry_run=1` (it bills a normal call there, except the labelled dry run an endpoint documents); quote with `scripts/estimate.py` (offline, `assets/endpoints.json`) or the section's **Pricing** line. At every level, report `credits_used` after.\n\n**If the task needs a whole list, price the whole walk before the first page.** Paging to completion multiplies the page cost by the page count, and a heading only shows one page. `coverage=full` on `instagram/followers` and `instagram/following` is the extreme case: 10 credits a page, about 50 accounts a page, so a 2,600-account list is roughly 520 credits. Quote that total and get agreement before starting ([Multi-page walks](references/cost-gate.md#multi-page-walks-coveragefull)).\n\nErrors: classify before retrying with [references/errors.md](references/errors.md). Credits and balance: `GET /v1/credits/balance` (0 credits); the ledger is `GET /v1/credits/transactions?limit=50` (0 credits).";
3
3
  export declare const ERRORS_GUIDE = "# Errors\n\nRead this when a call fails. The full code table (status, retryable, what to do) is generated in [api-overview.md](api-overview.md#error-codes); the `error.details` reasons are in [api-overview.md](api-overview.md#error-details-errordetails).\n\n## Classify before retrying\n\n- **Fix before retrying:** `MISSING_API_KEY`, `INVALID_API_KEY`, `INSUFFICIENT_CREDITS`, `KEY_BUDGET_EXCEEDED`, `INVALID_REQUEST`, `METHOD_NOT_ALLOWED`, `ENDPOINT_NOT_FOUND`, `PAYLOAD_TOO_LARGE`, and idempotency conflicts. Explain the corrective action and do not automatically repeat the same request.\n- **Wait before retrying:** `RATE_LIMITED`, `CONCURRENCY_LIMIT`, and `SERVICE_UNAVAILABLE`. Honour `Retry-After`, then use exponential backoff with jitter.\n- **Transient upstream failure:** `UPSTREAM_ERROR` and `INTERNAL_ERROR`. Retry at most once, then report the outage with the endpoint and request ID, never the credential.\n- **Not found:** `RESOURCE_NOT_FOUND` is a valid empty outcome, not a retry loop.\n\n## Act on `error.details`\n\nEvery error carries `error.retryable`, and many carry `error.details.reason`; act on it rather than on the status alone:\n\n- **402** (`balance_too_low`, `key_budget_reached`) says `retry_will_succeed: false`: never retry, point the user at `top_up_url` or `key_settings_url`. On a metered call `pricing: \"ceiling\"` means the quoted credits are the maximum hold, and `lower_cost_with` names the params that hold less.\n- **400 `page_limit`** (`max_page`, `narrow_with`): the source has no further pages for this query; stop paging and narrow the query instead. A 400 that says `Did you mean ...?` names the parameter or value to fix.\n- **404 `account_gone` / `account_private` / `handle_unresolved`**: follow `error.details.suggestion` once (for a YouTube handle, retry with the stored `channelId` to tell a rename from a removal), then report. `site_not_supported` on `web/scrape` is final; its `suggestion` names the SocialCrawl endpoint for a social link.\n- **404 `ENDPOINT_NOT_FOUND`** may suggest the right path; check the live registry (`GET /v1/utility/endpoints?search=`, free) before saying something is unsupported.\n\n## Retrying paid calls\n\nFor a retryable paid non-streaming request, send an `Idempotency-Key` before the first attempt and reuse it only for the identical payload. Do not automatically retry streaming requests. Never exceed one automatic retry unless the user explicitly asks for continued retries.\n\nFailed calls are refunded (upstream errors, circuit-breaker rejections, timeouts, not-found, empty results); a request rejected for bad params, a page past the source's last page, or a rate limit never deducts at all.";
@@ -1,4 +1,4 @@
1
1
  /** The skill's SKILL.md body and errors reference. Generated by scripts/generate-data.ts (T28) - do not hand-edit. */
2
- export const GUIDE = "# SocialCrawl API\n\nOne API key and one response envelope for social, commerce, and research data. Lists are `{ items, next_cursor?, total? }`; add `?format=raw` to skip the transform pipeline. Every file below lives in `references/`; open only the one the task needs.\n\n## API Key\n\nResolve the API key only when a live API call is needed. Documentation, capability, pricing, and code-generation questions do not need a key.\n\nCheck these sources in order without displaying their contents:\n\n1. **Environment variable:** use `SOCIALCRAWL_API_KEY` when it starts with `sc_` and is not an example placeholder.\n2. **Config file:** if the environment variable is absent, load `~/.config/socialcrawl/api_key` into `SOCIALCRAWL_API_KEY` in the current process. On POSIX shells, use `SOCIALCRAWL_API_KEY=\"$(<\"$HOME/.config/socialcrawl/api_key\")\"; export SOCIALCRAWL_API_KEY`. On PowerShell, use `$env:SOCIALCRAWL_API_KEY = (Get-Content -LiteralPath \"$HOME/.config/socialcrawl/api_key\" -Raw).Trim()`.\n3. **Missing key:** tell the user to create or rotate a key at https://socialcrawl.dev/dashboard and configure it as `SOCIALCRAWL_API_KEY` or in `~/.config/socialcrawl/api_key`. Do not ask them to paste a secret into chat. Stop before the live call until they say it is configured.\n\nNever print, paste, log, or return the key. Never place a literal key in generated code, a command, a URL, an error message, or a saved transcript. Keep `$SOCIALCRAWL_API_KEY` (POSIX) or `$env:SOCIALCRAWL_API_KEY` (PowerShell) as a variable reference in examples. If the key appeared in chat or output, advise the user to revoke it in the dashboard and create a replacement.\n\n## First Live Call\n\nBefore the first live call in a session:\n\n1. Resolve the API key using the steps above. If it is missing or a placeholder, stop before making the call.\n2. Verify it with the free balance endpoint (0 credits):\n ```bash\n curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/credits/balance\"\n ```\n3. If successful, show the balance and continue with the user's request.\n4. If it fails, report the error without including request headers or the key, then follow [references/errors.md](references/errors.md).\n\n## Freshness Check (do this once per session)\n\nThis file is a snapshot of the registry with this fingerprint:\n\n<!-- BEGIN:GENERATED:FRESHNESS (auto-generated by generate-skills.ts - SK-08) -->\n```text\nregistry_fingerprint: 32f6edd1da53c21e53cf301be3b7827085f467d04c047224a28ed248d8e62785\ngenerated_at: 2026-10-02\n```\n<!-- END:GENERATED:FRESHNESS -->\n\nBeside the balance check, make one free call:\n\n```bash\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/utility/endpoints?fingerprint=1\" | head -c 400\n```\n\n- **`data.fingerprint` equals `registry_fingerprint` above** - use the bundled files and move on.\n- **It differs** - this copy and the live API are out of sync (the skill or the server may be newer): a price, parameter or endpoint changed. Treat the live registry as the source of truth and resolve what the files cannot answer through `/v1/utility/*` (all free). Tell the user **once**, briefly: \"this SocialCrawl skill does not match the live API; run `npx skills update socialcrawl --yes` to refresh it.\" Then answer their actual question. Do not repeat it or ask permission.\n- **No `data.fingerprint`** (a 404, or an older server that answers with the plain list) - fall back to counts: compare `data.stats.platforms` and `data.stats.endpoints` from `/v1/utility/endpoints` with the totals at the top of [references/index.md](references/index.md). Live numbers HIGHER means behind, as above.\n- **The call fails** (no key yet, offline, non-200) - skip it silently. This check must never block the request.\n\n## Workflow\n\n1. **Route.** Find your job in [references/index.md](references/index.md) (Job to recipe link) and read only that recipe's section (cheapest chain, cost, pitfalls): `grep -n '^## ' references/recipes.md` gives the line numbers; do not open the whole file. No matching job: find the platform in the table below or in [references/index.md](references/index.md). For a job that needs several calls (a profile, then posts, then comments; a brand watch), the free planner `GET /v1/utility/plan?query=<the job in plain words>` (0 credits, runs nothing) returns the calls in order with params, price, and which step feeds which; its recipe matches are reliable, but check a single-endpoint or multi-source plan with find.\n **Free finder:** `GET /v1/utility/find?task=<the job in plain words>` returns the best endpoints with params filled and the credits held. Act on `results[0]` only when `uncertain` is false; otherwise show the options. Write or billing requests return no results. Every new `/v1/utility/*` route (find, plan, estimate) may 404 on an older server: fall back to the existing flow (index, recipes, the platform file).\n2. **Read one section, not one file.** Read the platform file's TOC (from the top until the first `## `: endpoint, cost, returns, use when), pick the row, then read only that section: `grep -nE '^## (GET|POST|PUT|PATCH|DELETE) /v1/<platform>/<resource> - ' references/<platform>.md`, and read from that line to the next `## `. The section carries the exact cost, cache TTL, pagination, every parameter, and the constraints checked before billing.\n3. **Estimate.** Build the exact request and apply the cost gate below (one line for a small flat call, the full preflight in [references/cost-gate.md](references/cost-gate.md) for anything metered or large). A heading's number can be a per-row or per-page unit, not the request total.\n4. **Call.** Resolve the key, then run the request exactly as the section shows it, keeping its HTTP method and body shape. If the user already asked to run this exact paid request, the cost disclosure is enough, except the Ask level: always ask (see the gate in the Cost rule); otherwise ask only before a paid call or wider scope they did not authorise.\n5. **Report.** Return the data, then `credits_used` and `credits_remaining`. For an async job report the hold at submission and the settled charge on completion.\n\n**Code requests:** read the section and cost-gate, write a snippet that reads `SOCIALCRAWL_API_KEY` from the environment with a comment stating the billing unit, and present it without running it.\n\n**Capability and pricing questions:** answer from the index and [references/pricing.md](references/pricing.md) (cost, tiers, packs, refunds, the free-endpoint list). Auth, envelope, pagination, labels, caching, idempotency: [references/api-overview.md](references/api-overview.md). The free `/v1/utility/*` calls answer from the live registry: `endpoints` (filter `?platform=`, `?search=`), `endpoint?id=tiktok/profile` (one endpoint, with measured field fill rates), `plan?query=`, `quickstart`.\n\n**Ambiguous platform:** if the user says \"get @nike's profile\" with no platform, ask which one.\n\n## Where to look\n\n| Need | Open |\n|------|------|\n| Any single platform (social, commerce, reviews and places, app stores, search/news/finance, research and dev, link-in-bio) | [index.md](references/index.md) lists every platform file with its endpoint count; open `references/<platform>.md` |\n| One call over many platforms: Prism composites, `search/multi`, `search/everywhere` | [prism.md](references/prism.md), [search.md](references/search.md) |\n| Scheduled re-runs with webhook delivery | [monitors.md](references/monitors.md) |\n| \"Which of MY list of accounts posted about X\" (Cohorts, not listening) | [cohorts.md](references/cohorts.md) |\n| Cost of a request or a whole paged walk | [cost-gate.md](references/cost-gate.md), [pricing.md](references/pricing.md) |\n| A failed call | [errors.md](references/errors.md) |\n\n> **Never answer \"not supported\" from this table alone.** It is only as new as this file, and a missing row is far more often a stale copy than a real gap. Before telling a user a platform, endpoint or capability does not exist, check the live registry - it is free:\n>\n> ```bash\n> curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n> \"https://www.socialcrawl.dev/v1/utility/endpoints?search=douyin\"\n> ```\n>\n> Each row carries `path`, `method`, `credits_label`, `required_params`, `one_of`, `optional_params`, `paginated` and `cache_ttl_seconds`: enough to make the call without this file. Only say it is unsupported when the search returns `total: 0`.\n\n**Comparing products across retailers:** Amazon, Walmart, Target, eBay and Home Depot share the canonical Product / Review / Seller schemas, so rows line up. Resolve each retailer's product id (ASIN, item id, TCIN, ...) with its own search, then fetch detail and reviews per retailer. `/v1/prism/product-reviews` is one composite over Amazon, Google Shopping and Trustpilot reviews only; for Walmart, Target or Home Depot call `<retailer>/reviews`.\n\n**Several platforms at once:** `/v1/search/multi` runs one query over several platforms' own search (each platform's page price, charged only for those that returned rows); `/v1/search/everywhere` (20 credits) plans, ranks, and clusters up to 17 sources; many profiles or post URLs go to `POST /v1/prism/profiles` / `POST /v1/prism/post-stats`, or the background job `POST /v1/prism/jobs`.\n\n## Making calls\n\nBase URL `https://www.socialcrawl.dev`. Most endpoints are GET with query parameters (URL-encode values):\n\n```\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n \"https://www.socialcrawl.dev/v1/{platform}/{resource}?{param}={value}\"\n```\n\n**Never assume the method.** Each endpoint section is headed by its real verb with a runnable curl. Batch reads, Prism jobs, web jobs, monitors, and cohorts use POST, PATCH, PUT, or DELETE with `content-type: application/json` (`web/parse` is multipart); the list, plus streaming (`Accept: text/event-stream`) and two-step endpoints that need an id from an earlier call, is in [api-overview.md](references/api-overview.md#non-get-routes-streaming-and-two-step-endpoints). Rate limits: 600 requests per minute and 50 concurrent per key; both return 429 with `Retry-After` and are never billed. Some endpoints are task-polled and take 10-45s: use a 60s timeout.\n\n## Reading a response\n\nDetails are in [api-overview.md](references/api-overview.md). Five rules before the first call:\n\n- **Placement.** `pagination` (`next_cursor`, `has_more`, `page_size`) and the optional `meta.hint` sit at the envelope root. `dropped`, `_warnings` and every page report (`labels`, `relevance`, `label_share`, `hydration`, `walk`, ...) sit inside `data`. Read `data._warnings`: an ignored parameter (`count was ignored; use limit (page size)`) or a handle that resolved to a different account (`resolved_to_different_handle`) is reported there, not as an error.\n- **Paging.** Send `pagination.next_cursor` back as `cursor` and stop on `has_more: false`, not on a short page or on `total`. A zero-match list is `200` with `items: []` at 0 credits.\n- **Default judgments are free.** Comment, post, review and keyword-search rows carry labels (`computed.labels`) and search rows a relevance score (`computed.relevance`) at no extra cost; `judgments=off` removes them. Opt-in presets (`label=spam|toxic|low_quality|quality|injection|mention`, `relevant_to=`) add **1 credit per 25 newly judged rows**. `relevance=filter` against the query is free.\n- **Spend controls.** Creator post lists take `stop_at_id` / `since` so a poll pays only for new pages (`pagination.stopped_at` says why it stopped). Keyword searches take `min_views`, `max_age_days`, `country` / `exclude_country`, `sort_rows=views`, `seen=<id>` (repeats refunded) and `max_pages` (1-5, **each page billed**).\n- **`meta.hint`** names one other call that does the job in fewer steps. Its message states the price when that call costs more; follow it only within what the user authorised.\n\n`include=` hydration joins rows to a sibling endpoint and is charged **per row on top of the page**, so never quote the plain heading cost for a hydrated call; the ceilings are in [cost-gate.md](references/cost-gate.md#row-hydration-include) and the traps in [api-overview.md](references/api-overview.md#row-hydration-include).\n\n## Cost rule\n\nCache hits, idempotent replays, every `/v1/utility/*` endpoint, and `/v1/credits/balance` cost 0 credits. Failed calls are refunded, and a request rejected for bad params, a page past the last page, or a rate limit never deducts. Metered endpoints hold an upfront ceiling and refund down to the work done, so the response `credits_used` is the real charge. Quote the total for the exact request, not the endpoint's base or unit cost. Scale the gate to the call:\n\n| Call | Gate |\n| --- | --- |\n| Flat price ≤ 5 credits, user asked for it | One line: `≈ N credits` |\n| Metered, multi-page, batch, monitor/cohort, or > 25 credits | Full preflight via `estimate.py` / `utility/estimate` |\n| Upfront hold (worst case) > 500 credits or over budget (the user's stated budget) | Ask before calling |\n\nAnything in between, or unsure of the price or params: quote first with the free `GET /v1/utility/estimate?id=<platform/resource>&<params>`. Any reply except a 404 means a current server (a 5xx or network failure is no reply: retry the estimate): use its quote, and `dry_run=1` is then free on any endpoint (validates, fetches nothing). A 404 or `ENDPOINT_NOT_FOUND` means an older server: do **not** send `dry_run=1` (it bills a normal call there, except the labelled dry run an endpoint documents); quote with `scripts/estimate.py` (offline, `assets/endpoints.json`) or the section's **Pricing** line. At every level, report `credits_used` after.\n\n**If the task needs a whole list, price the whole walk before the first page.** Paging to completion multiplies the page cost by the page count, and a heading only shows one page. `coverage=full` on `instagram/followers` and `instagram/following` is the extreme case: 10 credits a page, about 50 accounts a page, so a 2,600-account list is roughly 520 credits. Quote that total and get agreement before starting ([Multi-page walks](references/cost-gate.md#multi-page-walks-coveragefull)).\n\nErrors: classify before retrying with [references/errors.md](references/errors.md). Credits and balance: `GET /v1/credits/balance` (0 credits); the ledger is `GET /v1/credits/transactions?limit=50` (0 credits).";
2
+ export const GUIDE = "# SocialCrawl API\n\nOne API key and one response envelope for social, commerce, and research data. Lists are `{ items, next_cursor?, total? }`; add `?format=raw` to skip the transform pipeline. Every file below lives in `references/`; open only the one the task needs.\n\n## API Key\n\nResolve the API key only when a live API call is needed. Documentation, capability, pricing, and code-generation questions do not need a key.\n\nCheck these sources in order without displaying their contents:\n\n1. **Environment variable:** use `SOCIALCRAWL_API_KEY` when it starts with `sc_` and is not an example placeholder.\n2. **Config file:** if the environment variable is absent, load `~/.config/socialcrawl/api_key` into `SOCIALCRAWL_API_KEY` in the current process. On POSIX shells, use `SOCIALCRAWL_API_KEY=\"$(<\"$HOME/.config/socialcrawl/api_key\")\"; export SOCIALCRAWL_API_KEY`. On PowerShell, use `$env:SOCIALCRAWL_API_KEY = (Get-Content -LiteralPath \"$HOME/.config/socialcrawl/api_key\" -Raw).Trim()`.\n3. **Missing key:** tell the user to create or rotate a key at https://socialcrawl.dev/dashboard and configure it as `SOCIALCRAWL_API_KEY` or in `~/.config/socialcrawl/api_key`. Do not ask them to paste a secret into chat. Stop before the live call until they say it is configured.\n\nNever print, paste, log, or return the key. Never place a literal key in generated code, a command, a URL, an error message, or a saved transcript. Keep `$SOCIALCRAWL_API_KEY` (POSIX) or `$env:SOCIALCRAWL_API_KEY` (PowerShell) as a variable reference in examples. If the key appeared in chat or output, advise the user to revoke it in the dashboard and create a replacement.\n\n## First Live Call\n\nBefore the first live call in a session:\n\n1. Resolve the API key using the steps above. If it is missing or a placeholder, stop before making the call.\n2. Verify it with the free balance endpoint (0 credits):\n ```bash\n curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/credits/balance\"\n ```\n3. If successful, show the balance and continue with the user's request.\n4. If it fails, report the error without including request headers or the key, then follow [references/errors.md](references/errors.md).\n\n## Freshness Check (do this once per session)\n\nThis file is a snapshot of the registry with this fingerprint:\n\n<!-- BEGIN:GENERATED:FRESHNESS (auto-generated by generate-skills.ts - SK-08) -->\n```text\nregistry_fingerprint: 61a90b6d5dadcc038c3e4d4165f85f74177c77c5c5dfc9c2b7712c2f5d4ddaa4\ngenerated_at: 2026-10-07\n```\n<!-- END:GENERATED:FRESHNESS -->\n\nBeside the balance check, make one free call:\n\n```bash\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \"https://www.socialcrawl.dev/v1/utility/endpoints?fingerprint=1\" | head -c 400\n```\n\n- **`data.fingerprint` equals `registry_fingerprint` above** - use the bundled files and move on.\n- **It differs** - this copy and the live API are out of sync (the skill or the server may be newer): a price, parameter or endpoint changed. Treat the live registry as the source of truth and resolve what the files cannot answer through `/v1/utility/*` (all free). Tell the user **once**, briefly: \"this SocialCrawl skill does not match the live API; run `npx skills update socialcrawl --yes` to refresh it.\" Then answer their actual question. Do not repeat it or ask permission.\n- **No `data.fingerprint`** (a 404, or an older server that answers with the plain list) - fall back to counts: compare `data.stats.platforms` and `data.stats.endpoints` from `/v1/utility/endpoints` with the totals at the top of [references/index.md](references/index.md). Live numbers HIGHER means behind, as above.\n- **The call fails** (no key yet, offline, non-200) - skip it silently. This check must never block the request.\n\n## Workflow\n\n1. **Find the call first (free, 0 credits, runs nothing).** `GET /v1/utility/find?task=<the job in plain words>` ranks the endpoints for the job, each with `method`, `path`, `params_filled` (taken from your words), `missing` and `estimated_credits`. Call `results[0]` directly when `uncertain` is false: its method, path and params are the ready call (add any `missing` param, then apply the Cost rule). When `uncertain` is true, show the options. For a job that needs several calls (a profile, then posts, then comments; a brand watch), `GET /v1/utility/plan?query=<the job>` returns the calls in order with params, price, and which step feeds which. Write or billing requests return no results.\n2. **Fall back to the bundled files** when offline, when `find` or `plan` answers 404 (an older server: fall back to the existing flow), or when `uncertain` is true. Route with [Common jobs](#common-jobs) below, or grep [references/index.md](references/index.md): its Job to recipe table, then one line per endpoint (`grep -i transcript references/index.md`). For a recipe, read only its section: `grep -n '^## ' references/recipes.md` gives the line numbers; do not open the whole file. For an endpoint, read the platform file's TOC (from the top until the first `## `), then only its section: `grep -nE '^## (GET|POST|PUT|PATCH|DELETE) /v1/<platform>/<resource> - ' references/<platform>.md`, and read from that line to the next `## `. The section carries the exact cost, cache TTL, pagination, every parameter, the response fields, and the constraints checked before billing.\n3. **Estimate.** Build the exact request and apply the cost gate below (one line for a small flat call, the full preflight in [references/cost-gate.md](references/cost-gate.md) for anything metered or large). A heading's number can be a per-row or per-page unit, not the request total.\n4. **Call.** Resolve the key, then run the request exactly as the section shows it, keeping its HTTP method and body shape. If the user already asked to run this exact paid request, the cost disclosure is enough, except the Ask level: always ask (see the gate in the Cost rule); otherwise ask only before a paid call or wider scope they did not authorise.\n5. **Report.** Return the data, then `credits_used` and `credits_remaining`. For an async job report the hold at submission and the settled charge on completion.\n\n## Common jobs\n\nThe first call for the asks agents meet most, generated from the registry recipes (`{x}` is yours to fill). `find` gives the same answer with your values filled in.\n\n<!-- BEGIN:GENERATED:COMMON_JOBS (auto-generated by generate-skills.ts from registry recipes) -->\n| Job | First call | Then |\n|-----|------------|------|\n| Comments on a post to CSV | `GET /v1/tiktok/post/comments?url={url}&sort=recent&scan_pages=3` | `paginate.py` piped to `to_csv.py --archetype Comment`; any platform's `<platform>/post/comments`; [recipe](references/recipes.md#export-the-latest-n-comments-on-a-tiktok-video) |\n| Creators by niche, followers or country | `GET /v1/search/creators?query={niche}&sources=tiktok,instagram&min_followers={min_followers}` | `search/creators` has no country filter; [recipe](references/recipes.md#find-creators-in-a-niche); one country: [recipe](references/recipes.md#instagram-creators-from-one-country-about-a-topic); one country on a small budget: [recipe](references/recipes.md#instagram-creators-from-one-country-on-a-small-budget) |\n| A product's reviews across retailers | `GET /v1/prism/product-reviews?query={product}` | covers Amazon, Google Shopping and Trustpilot reviews; Walmart, Target, Home Depot: `<retailer>/reviews`; [recipe](references/recipes.md#one-report-on-a-products-reviews-across-marketplaces) |\n| Stock price and news | `GET /v1/finance/ticker-search?keyword={company}` | then `finance/quote` (`quote.price.current`) and `finance/news`; [recipe](references/recipes.md#a-stocks-current-price-and-latest-headlines) |\n| YouTube transcript | `GET /v1/youtube/video/transcript?url={url}` | [recipe](references/recipes.md#transcribe-a-video) |\n| Alert on new posts or changes | `POST /v1/monitors` (body `recipe: instagram/profile/posts`) | only when `GET /v1/utility/estimate?id=monitors` returns 200, send `?dry_run=1` first to validate and price without creating; otherwise describe the request and create nothing until the user agrees; a page: `web/monitors`; [recipe](references/recipes.md#track-a-creators-new-posts-every-day) |\n| Stats for a list of post URLs | `POST /v1/prism/post-stats` (JSON body `urls`) | a file of URLs: `batch.py --urls`; [recipe](references/recipes.md#engagement-stats-for-a-list-of-post-urls) |\n| Korean / Naver search | `GET /v1/naver/brief?query={keyword}&corpora=news,blog,cafearticle` | one corpus: `naver/blog/search`, `naver/news/search`; [recipe](references/recipes.md#what-korean-consumers-say-about-a-product-and-search-interest) |\n| Profile lookup | `GET /v1/tiktok/profile?handle={handle}` | any `<platform>/profile`; many handles: `prism/profiles`; [recipe](references/recipes.md#a-creators-profile-recent-posts-and-the-comments-on-them) |\n| Scrape a web page | `GET /v1/web/scrape?url={url}` | structured fields: `web/extract`; a whole site: `web/crawl` |\n| Brand mentions across the web | `GET /v1/prism/brand-mentions?keyword={brand}&date_from={start_date}&include=digest` | [recipe](references/recipes.md#watch-what-the-web-says-about-a-brand) |\n| One topic on several platforms | `GET /v1/search/multi?query={topic}&platforms=tiktok,instagram,youtube&relevance=filter` | [recipe](references/recipes.md#search-a-topic-on-several-platforms-at-once) |\n<!-- END:GENERATED:COMMON_JOBS -->\n\n## Helpers\n\nBundled scripts in `scripts/` (Python 3). They read the key from `SOCIALCRAWL_API_KEY` or `~/.config/socialcrawl/api_key` and never print it; `--help` on each gives the rest.\n\n```bash\npython3 scripts/sc.py tiktok/profile handle=nike # one call; JSON to stdout, credits_used to stderr\npython3 scripts/paginate.py tiktok/post/comments --items 500 --max-credits 20 url=<post_url> > rows.jsonl # page to N rows within a budget\npython3 scripts/to_csv.py --archetype Comment --in rows.jsonl --out comments.csv # rows to CSV with stable columns\npython3 scripts/batch.py --urls links.txt > stats.jsonl # stats for a file of post URLs (prism/post-stats, or one prism/jobs job past 500)\npython3 scripts/estimate.py tiktok/post/comments --items 500 --offline url=<post_url> # quote offline from assets/endpoints.json\n```\n\n**Code requests:** read the section and cost-gate, write a snippet that reads `SOCIALCRAWL_API_KEY` from the environment with a comment stating the billing unit, and present it without running it.\n\n**Capability and pricing questions:** answer from the index and [references/pricing.md](references/pricing.md) (cost, tiers, packs, refunds, the free-endpoint list). Auth, envelope, pagination, labels, caching, idempotency: [references/api-overview.md](references/api-overview.md). The free `/v1/utility/*` calls answer from the live registry: `endpoints` (filter `?platform=`, `?search=`), `endpoint?id=tiktok/profile` (one endpoint, with measured field fill rates), `plan?query=`, `quickstart`.\n\n**Ambiguous platform:** if the user says \"get @nike's profile\" with no platform, ask which one.\n\n## Where to look\n\n| Need | Open |\n|------|------|\n| Any single platform (social, commerce, reviews and places, app stores, search/news/finance, research and dev, link-in-bio) | [index.md](references/index.md) lists every platform file with its endpoint count; open `references/<platform>.md` |\n| One call over many platforms: Prism composites, `search/multi`, `search/everywhere` | [prism.md](references/prism.md), [search.md](references/search.md) |\n| Scheduled re-runs with webhook delivery | [monitors.md](references/monitors.md) |\n| \"Which of MY list of accounts posted about X\" (Cohorts, not listening) | [cohorts.md](references/cohorts.md) |\n| Cost of a request or a whole paged walk | [cost-gate.md](references/cost-gate.md), [pricing.md](references/pricing.md) |\n| A failed call | [errors.md](references/errors.md) |\n\n> **Never answer \"not supported\" from this table alone.** It is only as new as this file, and a missing row is far more often a stale copy than a real gap. Before telling a user a platform, endpoint or capability does not exist, check the live registry - it is free:\n>\n> ```bash\n> curl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n> \"https://www.socialcrawl.dev/v1/utility/endpoints?search=douyin\"\n> ```\n>\n> Each row carries `path`, `method`, `credits_label`, `required_params`, `one_of`, `optional_params`, `paginated` and `cache_ttl_seconds`: enough to make the call without this file. Only say it is unsupported when the search returns `total: 0`.\n\n**Comparing products across retailers:** Amazon, Walmart, Target, eBay and Home Depot share the canonical Product / Review / Seller schemas, so rows line up. Resolve each retailer's product id (ASIN, item id, TCIN, ...) with its own search, then fetch detail and reviews per retailer. `/v1/prism/product-reviews` is one composite over Amazon, Google Shopping and Trustpilot reviews only; for Walmart, Target or Home Depot call `<retailer>/reviews`.\n\n**Several platforms at once:** `/v1/search/multi` runs one query over several platforms' own search (each platform's page price, charged only for those that returned rows); `/v1/search/everywhere` (20 credits) plans, ranks, and clusters up to 17 sources; many profiles or post URLs go to `POST /v1/prism/profiles` / `POST /v1/prism/post-stats`, or the background job `POST /v1/prism/jobs`.\n\n## Making calls\n\nBase URL `https://www.socialcrawl.dev`. Most endpoints are GET with query parameters (URL-encode values):\n\n```\ncurl -s -H \"x-api-key: $SOCIALCRAWL_API_KEY\" \\\n \"https://www.socialcrawl.dev/v1/{platform}/{resource}?{param}={value}\"\n```\n\n**Never assume the method.** Each endpoint section is headed by its real verb with a runnable curl. Batch reads, Prism jobs, web jobs, monitors, and cohorts use POST, PATCH, PUT, or DELETE with `content-type: application/json` (`web/parse` is multipart); the list, plus streaming (`Accept: text/event-stream`) and two-step endpoints that need an id from an earlier call, is in [api-overview.md](references/api-overview.md#non-get-routes-streaming-and-two-step-endpoints). Rate limits: 600 requests per minute and 50 concurrent per key; both return 429 with `Retry-After` and are never billed. Some endpoints are task-polled and take 10-45s: use a 60s timeout.\n\n## Reading a response\n\nDetails are in [api-overview.md](references/api-overview.md). Five rules before the first call:\n\n- **Placement.** `pagination` (`next_cursor`, `has_more`, `page_size`) and the optional `meta.hint` sit at the envelope root. `dropped`, `_warnings` and every page report (`labels`, `relevance`, `label_share`, `hydration`, `walk`, ...) sit inside `data`. Read `data._warnings`: an ignored parameter (`count was ignored; use limit (page size)`) or a handle that resolved to a different account (`resolved_to_different_handle`) is reported there, not as an error.\n- **Paging.** Send `pagination.next_cursor` back as `cursor` and stop on `has_more: false`, not on a short page or on `total`. A zero-match list is `200` with `items: []` at 0 credits.\n- **Default judgments are free.** Comment, post, review and keyword-search rows carry labels (`computed.labels`) and search rows a relevance score (`computed.relevance`) at no extra cost; `judgments=off` removes them. Opt-in presets (`label=spam|toxic|low_quality|quality|injection|mention`, `relevant_to=`) add **1 credit per 25 newly judged rows**. `relevance=filter` against the query is free.\n- **Spend controls.** Creator post lists take `stop_at_id` / `since` so a poll pays only for new pages (`pagination.stopped_at` says why it stopped). Keyword searches take `min_views`, `max_age_days`, `country` / `exclude_country`, `sort_rows=views`, `seen=<id>` (repeats refunded) and `max_pages` (1-5, **each page billed**).\n- **`meta.hint`** names one other call that does the job in fewer steps. Its message states the price when that call costs more; follow it only within what the user authorised.\n\n`include=` hydration joins rows to a sibling endpoint and is charged **per row on top of the page**, so never quote the plain heading cost for a hydrated call; the ceilings are in [cost-gate.md](references/cost-gate.md#row-hydration-include) and the traps in [api-overview.md](references/api-overview.md#row-hydration-include).\n\n## Cost rule\n\nCache hits, idempotent replays, every `/v1/utility/*` endpoint, and `/v1/credits/balance` cost 0 credits. Failed calls are refunded, and a request rejected for bad params, a page past the last page, or a rate limit never deducts. Metered endpoints hold an upfront ceiling and refund down to the work done, so the response `credits_used` is the real charge. Quote the total for the exact request, not the endpoint's base or unit cost. Scale the gate to the call:\n\n| Call | Gate |\n| --- | --- |\n| Flat price ≤ 5 credits, user asked for it | One line: `≈ N credits` |\n| Metered, multi-page, batch, monitor/cohort, or > 25 credits | Full preflight via `estimate.py` / `utility/estimate` |\n| Upfront hold (worst case) > 500 credits or over budget (the user's stated budget) | Ask before calling |\n\nAnything in between, or unsure of the price or params: quote first with the free `GET /v1/utility/estimate?id=<platform/resource>&<params>`. Any reply except a 404 means a current server (a 5xx or network failure is no reply: retry the estimate): use its quote, and `dry_run=1` is then free on any endpoint (validates, fetches nothing). A 404 or `ENDPOINT_NOT_FOUND` means an older server: do **not** send `dry_run=1` (it bills a normal call there, except the labelled dry run an endpoint documents); quote with `scripts/estimate.py` (offline, `assets/endpoints.json`) or the section's **Pricing** line. At every level, report `credits_used` after.\n\n**If the task needs a whole list, price the whole walk before the first page.** Paging to completion multiplies the page cost by the page count, and a heading only shows one page. `coverage=full` on `instagram/followers` and `instagram/following` is the extreme case: 10 credits a page, about 50 accounts a page, so a 2,600-account list is roughly 520 credits. Quote that total and get agreement before starting ([Multi-page walks](references/cost-gate.md#multi-page-walks-coveragefull)).\n\nErrors: classify before retrying with [references/errors.md](references/errors.md). Credits and balance: `GET /v1/credits/balance` (0 credits); the ledger is `GET /v1/credits/transactions?limit=50` (0 credits).";
3
3
  export const ERRORS_GUIDE = "# Errors\n\nRead this when a call fails. The full code table (status, retryable, what to do) is generated in [api-overview.md](api-overview.md#error-codes); the `error.details` reasons are in [api-overview.md](api-overview.md#error-details-errordetails).\n\n## Classify before retrying\n\n- **Fix before retrying:** `MISSING_API_KEY`, `INVALID_API_KEY`, `INSUFFICIENT_CREDITS`, `KEY_BUDGET_EXCEEDED`, `INVALID_REQUEST`, `METHOD_NOT_ALLOWED`, `ENDPOINT_NOT_FOUND`, `PAYLOAD_TOO_LARGE`, and idempotency conflicts. Explain the corrective action and do not automatically repeat the same request.\n- **Wait before retrying:** `RATE_LIMITED`, `CONCURRENCY_LIMIT`, and `SERVICE_UNAVAILABLE`. Honour `Retry-After`, then use exponential backoff with jitter.\n- **Transient upstream failure:** `UPSTREAM_ERROR` and `INTERNAL_ERROR`. Retry at most once, then report the outage with the endpoint and request ID, never the credential.\n- **Not found:** `RESOURCE_NOT_FOUND` is a valid empty outcome, not a retry loop.\n\n## Act on `error.details`\n\nEvery error carries `error.retryable`, and many carry `error.details.reason`; act on it rather than on the status alone:\n\n- **402** (`balance_too_low`, `key_budget_reached`) says `retry_will_succeed: false`: never retry, point the user at `top_up_url` or `key_settings_url`. On a metered call `pricing: \"ceiling\"` means the quoted credits are the maximum hold, and `lower_cost_with` names the params that hold less.\n- **400 `page_limit`** (`max_page`, `narrow_with`): the source has no further pages for this query; stop paging and narrow the query instead. A 400 that says `Did you mean ...?` names the parameter or value to fix.\n- **404 `account_gone` / `account_private` / `handle_unresolved`**: follow `error.details.suggestion` once (for a YouTube handle, retry with the stored `channelId` to tell a rename from a removal), then report. `site_not_supported` on `web/scrape` is final; its `suggestion` names the SocialCrawl endpoint for a social link.\n- **404 `ENDPOINT_NOT_FOUND`** may suggest the right path; check the live registry (`GET /v1/utility/endpoints?search=`, free) before saying something is unsupported.\n\n## Retrying paid calls\n\nFor a retryable paid non-streaming request, send an `Idempotency-Key` before the first attempt and reuse it only for the identical payload. Do not automatically retry streaming requests. Never exceed one automatic retry unless the user explicitly asks for continued retries.\n\nFailed calls are refunded (upstream errors, circuit-breaker rejections, timeouts, not-found, empty results); a request rejected for bad params, a page past the source's last page, or a rate limit never deducts at all.";
4
4
  //# sourceMappingURL=guide.js.map