socialcrawl-mcp 2.0.1 → 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.
@@ -9,7 +9,7 @@ export declare const TIMEOUT_MS = 30000;
9
9
  export declare const INLINE_MAX_ROWS = 200;
10
10
  export declare const INLINE_MAX_BYTES = 60000;
11
11
  export declare const SERVER_NAME = "socialcrawl-mcp";
12
- export declare const SERVER_VERSION = "2.0.1";
12
+ export declare const SERVER_VERSION = "2.0.2";
13
13
  /**
14
14
  * Inside a normalised `socialcrawl_request` params object: the names of the
15
15
  * endpoint params that arrived as top-level arguments and were moved into
package/dist/constants.js CHANGED
@@ -13,7 +13,7 @@ export const INLINE_MAX_BYTES = 60_000;
13
13
  // (CREDIT_LADDER) alongside the cache TTLs, so a ladder change cannot leave a
14
14
  // stale copy behind. Import it from there.
15
15
  export const SERVER_NAME = "socialcrawl-mcp";
16
- export const SERVER_VERSION = "2.0.1";
16
+ export const SERVER_VERSION = "2.0.2";
17
17
  /**
18
18
  * Inside a normalised `socialcrawl_request` params object: the names of the
19
19
  * endpoint params that arrived as top-level arguments and were moved into
@@ -753,9 +753,10 @@ Monitors are **not** registry endpoints — they live at \`/v1/monitors/*\` and
753
753
 
754
754
  - \`recipe\` (required) — any registered endpoint or Prism composite as \`platform/resource\` (e.g. \`prism/brand-mentions\`, \`tiktok/profile\`).
755
755
  - \`cadence\` (required) — \`hourly\` \| \`daily\` \| \`weekly\`, or a cron expression.
756
- - \`webhook_url\` (required) — HTTPS endpoint that receives each run, signed with \`x-socialcrawl-signature\` (HMAC-SHA256, timestamped).
756
+ - \`webhook_url\` (required unless \`track\` is set) — HTTPS endpoint that receives each run, signed with \`x-socialcrawl-signature\` (HMAC-SHA256, timestamped).
757
757
  - \`params\` — parameters passed to the recipe every run.
758
- - \`alert_rules\` — \`[{ metric, op, value, window? }]\`. Ops: \`gt\`, \`lt\`, \`gte\`, \`lte\`, \`abs_change_gt\`, \`pct_change_gt\`, \`pct_change_lt\` (the change ops compare a run to the previous comparable run; \`window\` is \`1d\` \| \`1w\`). To alert on new items, use the \`rows_new\` metric (rows not seen in the previous run; tracking monitors, ops \`gt\` / \`gte\`): \`{"metric":"rows_new","op":"gt","value":0}\`.
758
+ - \`alert_rules\` — \`[{ metric, op, value, window? }]\`. Ops: \`gt\`, \`lt\`, \`gte\`, \`lte\`, \`abs_change_gt\`, \`pct_change_gt\`, \`pct_change_lt\` (the change ops compare a run to the previous comparable run; \`window\` is \`1d\` \| \`1w\`). To alert on new items, use the \`rows_new\` metric (rows not seen in the previous run; ops \`gt\` / \`gte\`): \`{"metric":"rows_new","op":"gt","value":0}\`. \`rows_new\` requires \`track\` (below): without it the create is refused with "rows_new needs track".
759
+ - \`track\` — makes a tracking monitor that keeps numbers per row between runs: \`{ metrics, row_key?, max_rows? }\`. \`metrics\` is 1-20 paths to numbers: \`items[].<numeric path>\` reads one per row of a list recipe (e.g. \`items[].post.engagement.views\`; the part after \`items[].\` is relative to the row), and a plain dot path reads one off the page (e.g. \`author.followers\`). \`row_key\` is the dot path of a stable id inside a row (default: the row's own id, e.g. \`post.id\`; required when the rows have none); \`max_rows\` is 1-200 (default 100). With \`track\`, \`webhook_url\` is optional (a download-only monitor). New-items alert, whole: \`track: { metrics: ["items[].post.engagement.views"] }\`, \`alert_rules: [{"metric":"rows_new","op":"gt","value":0}]\`, \`suppress_webhook_unless_alert: true\`; keep \`track\` and \`alert_rules\` together.
759
760
  - \`suppress_webhook_unless_alert\` — only deliver the webhook when a rule trips.
760
761
  - \`name\`, \`output_schema\`, \`webhook_secret\` — optional.
761
762
 
@@ -819,7 +819,7 @@ export const ENDPOINTS = [
819
819
  { name: "user_id", type: "string", description: "TikTok user id. Use this for faster responses." },
820
820
  { name: "sort_by", type: "enum", enumValues: ["latest", "popular"], description: "Accepted for compatibility and ignored on this endpoint: neither `latest` nor `popular` reorders the page. Videos come back in the source's own order, described above. To rank a creator's videos by views or likes, page through with `max_cursor` and sort the collected rows yourself." },
821
821
  { name: "max_cursor", type: "string", description: "Cursor to get more videos. Get 'max_cursor' from previous response." },
822
- { name: "region", type: "string", description: "Region (Country) you want the proxy in. Defaults to US." },
822
+ { name: "region", type: "string", description: "Region (Country) you want the proxy in. Defaults to US. It does not filter the videos. The country TikTok registers each video to is post.ext.region." },
823
823
  { name: "trim", type: "boolean", description: "Accepted for compatibility; the response is already the canonical shape, so this flag has no effect." },
824
824
  { name: "format", type: "enum", enumValues: ["stationery"], description: "Optional. stationery files each video into wedding, birthday, birth, sympathy, seasonal greeting, or leaves it ungrouped. data.format_buckets gives the counts, the ungrouped share, and a by-day count when the page spans more than one day. A null save count stays null. brief= skips the walk when the page is not about that subject. No extra credits." },
825
825
  { name: "brief", type: "string", description: "Optional, with format=stationery. The subject these videos should be about. When the page is not about it, data.format_buckets.skip_creator is true and the videos are not filed." },
@@ -842,7 +842,7 @@ export const ENDPOINTS = [
842
842
  pricing: { cost: 1, tier: "standard", ladderCost: 1, model: "metered", minCost: 1, maxCost: 5, description: "1 credit per page. The default labels (sponsored, intent, niche) are free. label=mention, or label=intent with offer=, holds 4 extra credits and refunds down to 1 credit per started 25 posts that were newly judged: posts already labelled are free, a page where nothing could be judged refunds the whole extra, and a cached page is free." },
843
843
  archetype: "PostList",
844
844
  summary: "List TikTok user videos",
845
- description: "Returns a paginated list of recent public videos posted by a TikTok user. Each video includes view count, like count, comment count, share count, caption, and thumbnail URL. Profiles with TikTok 'audience controls' enabled (a login/age wall in the browser) are supported when looked up by `handle`; page-1 order on those gated accounts may follow recency rather than pinned-first.",
845
+ description: "Returns a paginated list of recent public videos posted by a TikTok user. Each video includes view count, like count, comment count, share count, caption, and thumbnail URL. `post.ext.region` is the ISO 3166-1 alpha-2 country TikTok registers that video to, normally the creator's account country when they posted. It is not the viewer's country, and a video with no registered country has it null. The creator's account country on its own is `author.location` from `/v1/tiktok/profile`. Profiles with TikTok 'audience controls' enabled (a login/age wall in the browser) are supported when looked up by `handle`; page-1 order on those gated accounts may follow recency rather than pinned-first.",
846
846
  budget_ms: 20000,
847
847
  pagination: { style: "cursor", nativeParam: "max_cursor" },
848
848
  cache: { category: "post", ttlSeconds: 600 },
@@ -1191,7 +1191,7 @@ export const ENDPOINTS = [
1191
1191
  pricing: { cost: 1, tier: "standard", ladderCost: 1, model: "metered", minCost: 1, maxCost: 5, description: "1 credit per page. The default labels (sponsored, intent, niche) are free. label=mention, or label=intent with offer=, holds 4 extra credits and refunds down to 1 credit per started 25 posts that were newly judged: posts already labelled are free, a page where nothing could be judged refunds the whole extra, and a cached page is free. With `max_pages`, each page walked is billed at this price (a cached page is free). With `seen`, a page's price falls with its share of rows you already received under that id; credits for joined data (`include=`) are never discounted." },
1192
1192
  archetype: "PostList",
1193
1193
  summary: "Search TikTok by hashtag",
1194
- description: "Searches TikTok for videos under a specific hashtag. Returns matching videos with engagement metrics and author info.",
1194
+ description: "Searches TikTok for videos under a specific hashtag. Returns matching videos with engagement metrics and author info. `post.ext.region` is the ISO country TikTok registers each video to, when the source sends one.",
1195
1195
  budget_ms: 20000,
1196
1196
  pagination: { style: "cursor", nativeParam: "cursor" },
1197
1197
  cache: { category: "search", ttlSeconds: 120 },
@@ -2166,7 +2166,7 @@ export const ENDPOINTS = [
2166
2166
  pricing: { cost: 1, tier: "standard", ladderCost: 1, model: "ladder" },
2167
2167
  archetype: "Author",
2168
2168
  summary: "Get Instagram user profile",
2169
- description: "Returns public profile information for an Instagram user including the exact integer follower count, following count, bio, profile picture URL, and verification status. `author.posts_count` is the account's lifetime post count, for accounts of any size, in the same call and for the same 1 credit. In the rare case that count cannot be read in time the leaf is null rather than a wrong number, and a repeat call normally fills it. Age-restricted (18+) profiles are supported. When the account publishes a contact address in its bio, it is returned as `author.ext.public_email`; otherwise that leaf is null. Instagram's in-app tap-to-email button is not readable from any public surface, so the bio is the only source for it.",
2169
+ description: "Returns public profile information for an Instagram user including the exact integer follower count, following count, bio, profile picture URL, and verification status. `author.posts_count` is the account's lifetime post count, for accounts of any size, in the same call and for the same 1 credit. In the rare case that count cannot be read in time the leaf is null rather than a wrong number, and a repeat call normally fills it. Age-restricted (18+) profiles are supported. When the account publishes a contact address in its bio, it is returned as `author.ext.public_email`; otherwise that leaf is null. Instagram's in-app tap-to-email button is not readable from any public surface, so the bio is the only source for it. To vet a creator by market, call /v1/instagram/profile/about instead: it returns the follower count and the declared country in one call, at the same price, so there is no need to call both.",
2170
2170
  budget_ms: 20000,
2171
2171
  cache: { category: "profile", ttlSeconds: 900 },
2172
2172
  upstream: { kind: "scrapecreators", fallbackKinds: ["hiker", "rapidapi-prosocial"] },
@@ -2204,7 +2204,7 @@ export const ENDPOINTS = [
2204
2204
  pricing: { cost: 1, tier: "standard", ladderCost: 1, model: "ladder" },
2205
2205
  archetype: "Author",
2206
2206
  summary: "Get Instagram account transparency details",
2207
- description: "Returns the data behind Instagram's \"About this account\" panel for a public account: the country the account is based in (`author.ext.country`), the month it joined (`author.ext.account_created`), and the public contact address and phone the account publishes (`author.ext.public_email`, `author.ext.public_phone`). Country is the account's own declared country, not the country you are calling from. The same call returns the profile itself: follower and following counts, bio, avatar, verification, and the account's lifetime post count as `author.posts_count`. Coverage follows what Instagram publishes: an account that shows no transparency panel returns null for those fields.",
2207
+ description: "Returns the data behind Instagram's \"About this account\" panel for a public account: the country the account is based in (`author.ext.country`), the month it joined (`author.ext.account_created`), and the public contact address and phone the account publishes (`author.ext.public_email`, `author.ext.public_phone`). Country is the account's own declared country, not the country you are calling from. The same call returns the profile itself: follower and following counts (`author.followers`), bio, avatar, verification, and the account's lifetime post count as `author.posts_count`. It gives the follower count and the declared country in one call, so there is no need to call /v1/instagram/profile as well. Coverage follows what Instagram publishes: an account that shows no transparency panel returns null for those fields.",
2208
2208
  budget_ms: 20000,
2209
2209
  cache: { category: "profile", ttlSeconds: 900 },
2210
2210
  upstream: { kind: "hiker", fallbackKinds: ["apify-instagram-profile"] },
@@ -11450,7 +11450,7 @@ export const ENDPOINTS = [
11450
11450
  },
11451
11451
  taxonomy: { purpose: "data_retrieval", job_family: "trends_and_charts", takes_item_id_from_another_endpoint: false },
11452
11452
  },
11453
- // --- trustpilot (2 endpoints) ---
11453
+ // --- trustpilot (3 endpoints) ---
11454
11454
  {
11455
11455
  platform: "trustpilot",
11456
11456
  resource: "business-search",
@@ -11507,7 +11507,7 @@ export const ENDPOINTS = [
11507
11507
  pricing: { cost: 5, tier: "advanced", ladderCost: 5, model: "metered", minCost: 5, maxCost: 9, description: "5 credits per page. The default labels (sentiment, issue) are free. label=reports, incentivized or injection holds 4 extra credits and refunds down to 1 credit per started 25 reviews that were newly judged (the first 100 reviews of a page are judged): reviews already labelled are free, a page where nothing could be judged refunds the whole extra, and a cached page is free." },
11508
11508
  archetype: "ReviewList",
11509
11509
  summary: "Get Trustpilot reviews for a business",
11510
- description: "Returns a unified ReviewList of customer reviews for a business on Trustpilot, keyed by its domain (`entity_id` on every review). Each review carries the star rating, full text, title, verified-status, language (reviews arrive in many languages: filter client-side via `language`), reviewer profile, owner/brand `responses[]`, and publish date. Reviews are about the COMPANY (shipping, refunds, support), never a specific product: for product reviews use /v1/google_shopping/reviews or /v1/amazon/reviews. Get the domain from /v1/trustpilot/business-search. The platform exposes no deeper pagination: `depth` caps at 200 (the most recent / most relevant); a business with no Trustpilot reviews returns 404 (auto-refunded). Read from a task-based upstream (first calls ~15-45s, then cached).",
11510
+ description: "Returns a unified ReviewList of customer reviews for a business on Trustpilot, keyed by its domain (`entity_id` on every review). Each review carries the star rating, full text, title, verified-status, language (reviews arrive in many languages: filter client-side via `language`), reviewer profile, owner/brand `responses[]`, and publish date. Reviews are about the COMPANY (shipping, refunds, support), never a specific product: for product reviews use /v1/google_shopping/reviews or /v1/amazon/reviews. Get the domain from /v1/trustpilot/business-search. The platform exposes no deeper pagination: `depth` caps at 200 (the most recent / most relevant); a business with no Trustpilot reviews returns 404 (auto-refunded). Read from a task-based upstream (a short depth is usually under a minute; depth=200 can take about a minute, then cached).",
11511
11511
  singlePage: "Depth-based fan-out: page size is controlled by depth, one call.",
11512
11512
  cache: { category: "comments", ttlSeconds: 300 },
11513
11513
  upstream: { kind: "dfs-trustpilot" },
@@ -11529,6 +11529,34 @@ export const ENDPOINTS = [
11529
11529
  },
11530
11530
  taxonomy: { purpose: "data_retrieval", job_family: "reviews_and_ratings", takes_item_id_from_another_endpoint: false },
11531
11531
  },
11532
+ {
11533
+ platform: "trustpilot",
11534
+ resource: "reviews/history",
11535
+ method: "POST",
11536
+ params: [
11537
+ { name: "domain", required: true, description: "The business domain, for example booking.com.", example: "booking.com" },
11538
+ { name: "depth", required: true, description: "How many reviews to collect, an integer from 1 to 10000. Page the result with GET /v1/trustpilot/reviews/history/{job_id}?offset=&limit=.", example: "772" },
11539
+ ],
11540
+ optionalParams: [],
11541
+ oneOfGroups: [],
11542
+ creditTier: "standard",
11543
+ creditCost: 1,
11544
+ pricing: { cost: 1, tier: "standard", ladderCost: 1, model: "metered", minCost: 6, maxCost: 10005, description: "1 credit per returned review, plus 5 credits to open. Submitting holds depth plus 5 credits and refunds the unused portion when the job settles." },
11545
+ archetype: "Analytics",
11546
+ summary: "Start a Trustpilot review history job",
11547
+ description: "Starts a job that collects up to `depth` reviews for one Trustpilot domain and returns a job id. Read a page with GET /v1/trustpilot/reviews/history/{job_id}?offset=&limit=. `depth` is an integer from 1 to 10000. GET /v1/trustpilot/reviews is unchanged and still returns at most 200 reviews.",
11548
+ execution: "async",
11549
+ cache: { category: "comments", ttlSeconds: 0 },
11550
+ upstream: { kind: "apify-review-history" },
11551
+ tags: ["trustpilot"],
11552
+ purpose: {
11553
+ summary: "Start a Trustpilot review history job",
11554
+ returns: "Starts a background job that collects up to depth reviews (1 to 10,000) of one business on Trustpilot by its domain, and returns its job id right away, holding depth plus 5 credits.",
11555
+ use_when: "Use it when you need more of a company's review history than GET /v1/trustpilot/reviews returns (200 at most); read the reviews later by job id with offset and limit.",
11556
+ not_for: "Not for a quick look at a company's latest reviews (trustpilot/reviews) or reviews of one product (Amazon or Google Shopping reviews).",
11557
+ },
11558
+ taxonomy: { purpose: "data_retrieval", job_family: "reviews_and_ratings", takes_item_id_from_another_endpoint: false },
11559
+ },
11532
11560
  // --- g2 (7 endpoints) ---
11533
11561
  {
11534
11562
  platform: "g2",
@@ -16480,11 +16508,12 @@ export const ENDPOINTS = [
16480
16508
  platform: "utility",
16481
16509
  resource: "plan",
16482
16510
  method: "GET",
16483
- params: [
16484
- { name: "query", required: true, description: "The job in plain words, in any language. Up to 600 characters are read", example: "Combine @acme's TikTok profile with their recent videos and the comments on them" },
16511
+ params: [],
16512
+ optionalParams: [
16513
+ { name: "query", type: "string", description: "The job in plain words, in any language. Up to 600 characters are read. Provide this or task", example: "Combine @acme's TikTok profile with their recent videos and the comments on them" },
16514
+ { name: "task", type: "string", description: "Alias for query (utility/find's name). Provide this or query" },
16485
16515
  ],
16486
- optionalParams: [],
16487
- oneOfGroups: [],
16516
+ oneOfGroups: [["query", "task"]],
16488
16517
  creditTier: "standard",
16489
16518
  creditCost: 0,
16490
16519
  pricing: { cost: 0, tier: "standard", ladderCost: 1, model: "flat", description: "Free (0 credits)" },
@@ -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: afebb7b68955b5ac4a2ca4099b78b61d5db084c5e24abe501604d8c3823b35cc\ngenerated_at: 2026-10-03\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}` | one country: `instagram/search/reels` with `country`; [recipe](references/recipes.md#find-creators-in-a-niche) |\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).";
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: afebb7b68955b5ac4a2ca4099b78b61d5db084c5e24abe501604d8c3823b35cc\ngenerated_at: 2026-10-03\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}` | one country: `instagram/search/reels` with `country`; [recipe](references/recipes.md#find-creators-in-a-niche) |\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).";
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