---
agent:
  instructions: "Search the SocialTap docs with keywords or a question instead of crawling pages: GET https://socialtap.dev/.well-known/search?q={query} returns the best sections as Markdown (JSON with Accept: application/json), free and without a key."
  endpoint: "https://socialtap.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://socialtap.dev/docs/agents/#docs-for-agents"
---
# CLI

> Setting SocialTap up for your user? Follow https://socialtap.dev/setup.md.

Agents and accounts

Call any endpoint from a shell, run batches from a file, download files and set up your coding agents.

The CLI calls every endpoint from a shell: one command per endpoint, a table or JSON out, batches from a file and exit codes a script can branch on. It needs Node.js. Install it once, sign in, then call an endpoint:

Shell:

```shell
npm install -g socialtap   # once; or run each with npx
socialtap login
socialtap tiktok profile nasa
```

`login` opens your browser, and the key it saves is readable only by you. `search` finds the endpoint for a need or a link, and `describe` states any endpoint's params, price and output as JSON. Neither needs a key.

## Which to use: MCP, CLI or SDK

| When | Use | Why |
| --- | --- | --- |
| An agent gets data for you in a chat or a coding session | [The MCP server](https://socialtap.dev/mcp/) | Tools the agent calls with no code to write. It signs in with your browser, and the tools find the endpoint for a need or a link. |
| A shell: a one-off lookup, a file of links, a script or cron, an agent that runs commands | [The CLI](https://socialtap.dev/docs/cli/index.md) (`npx socialtap`) | One command per endpoint, a table or JSON out, batches from a file that resume, exit codes a script can branch on. |
| Code you ship: an app, a pipeline, a scheduled job | [The TypeScript SDK](https://socialtap.dev/docs/sdks/typescript/index.md) | Typed methods for every endpoint, with retries and pagination, and the API key from your environment. |

## Sign in

- `login` signs you in with your browser and saves a key for this computer. `whoami` shows the account, the balance and where the key comes from.
- The key comes from `--api-key`, then `SOCIALTAP_API_KEY`, then the saved one. Pass `--api-key -` to read it from stdin.
- An agent without a browser runs `login --non-interactive`: it prints a link and a code as JSON. The agent shows them to you, then runs `login --complete`, which waits for your approval and saves the key.
- `--profile <name>` keeps a second key and origin beside the first, for another account or a staging deployment.

## Call an endpoint

The command is the platform and the endpoint, then the link, handle or query the endpoint takes. Every other param is a flag, in kebab-case or snake_case. `socialtap <platform>` lists a platform's endpoints, and `socialtap <platform> <endpoint> --help` lists its params, its price and an example.

Shell:

```shell
socialtap tiktok profile nasa --max-age 3600
socialtap tiktok profile nasa --dry-run
socialtap tiktok profile nasa --jq .data
```

`--max-age` accepts a stored answer up to that many seconds old, free. `--dry-run` prints the request and its price and sends nothing. A failed request is free, and `--max-credits` caps what a call may cost: one that would cost more stops first, free.

## Choose the output

At a terminal you get a table, or one item's fields, with what the call cost. Piped, or run by a coding agent, you get compact JSON. `--format json|jsonl|table|csv|md` picks one, and `-o <file>` writes it to a file (the format from its extension). The CLI never replaces a file without `--force`, and checks that before it sends anything.

`--jq <expr>` filters the JSON without installing jq, and a mistake in it is refused before the call. When the filter fails on an answer you paid for, the answer is printed unfiltered and the error gives the command that reads it again free. `--concise` keeps the main fields and leaves nulls out; `--full` returns every field.

## Walk a list

On a list endpoint, `--all` walks every page from the first (or from `--cursor`): a table at a terminal, one item per line otherwise. `--max-pages` stops it early and `--max-credits` caps the whole walk. A walk that stops prints the command to resume it.

Shell:

```shell
socialtap amazon offers https://www.amazon.com/Apple-AirPods-Pro-3/dp/B0FQFB8FMG --all --max-pages 3 -o items.jsonl
```

## Run a batch from a file

Every endpoint command takes `--input-file <file>`: one link, handle or query per line, or a JSON object of params.

Shell:

```shell
socialtap tiktok profile --input-file handles.txt -o results.jsonl
socialtap tiktok profile --input-file handles.txt -o results.jsonl --resume
```

Each line gives one record, in input order, with its data or its error. A line that fails doesn't stop the rest. `--max-credits` caps the whole batch. The CLI keeps the batch's progress in its own state directory once the first request is sent, so `--resume` continues a batch that stopped without paying again for the lines it finished. `--job` runs it as background jobs, so no terminal has to stay open.

## Keep only what's new

`--archive <file>` records the IDs of the items a run returns and leaves out the ones an earlier run saw. With `--all` on a newest-first list, `--break-on-existing` stops at the first item already in the archive, so a daily run reads only what's new.

## Download videos and photos

`--download[=<dir>]` saves each item's files under a name template (`--name-template`) and skips files already there. The files go to the directory; the data still goes to stdout or `-o`.

## Jobs, webhooks and local testing

- `jobs` creates background jobs from a file, waits for them and reads their results. See [Jobs and batches](https://socialtap.dev/docs/jobs/index.md).
- `webhooks` lists, creates and deletes webhook endpoints and sends a test event.
- `listen --forward-to <url>` sends your account's events to a local URL, signed as webhooks are, to test a receiver.

## Connect your coding agents

`init` sets up every MCP client it finds on this computer, and the agent running it: the MCP server in each one's config and the Agent Skill where it reads skills. Each client signs you in with your browser; `--api-key` stores your key in their configs instead. `--agent claude,cursor` picks clients, and one that isn't installed is an error, never skipped. A server of the same name that isn't this one is left alone unless you pass `--force`, and a config init can't edit safely is left as it is, with what to paste. `--project` writes this project's config files instead, to commit. `--dry-run` prints the plan, `--status` what is set up where, and `--uninstall` removes only what it added.

`init --default` also tells each agent to read social media links with the MCP tools, not its web fetch. It writes a short marked block into the agent's instructions file (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, a Cursor rule), once per file and never a line outside it. Running it again updates the block, and `--default=off` removes it.

`mcp` is a local MCP server for clients that run local servers only. It bridges to the hosted server with the CLI's sign-in; `--tools` and `--platforms` choose the tools it lists. The [docs for AI agents](https://socialtap.dev/docs/agents/index.md) list every client and its one-click install.

## Agent mode

The CLI detects a coding agent from its environment and answers it in compact, concise JSON, with no color and no prompts. `--agent yes|no` overrides the detection.

## Errors

Piped or run by an agent, an error is one JSON object on stderr with a stable `code`, a `message` and a `remediation`. At a terminal you read the same as lines. The exit code is its class (below). A batch with some lines failed, and a `--jq` that fails on an answer you paid for, each have a code of their own.

## Commands

### Data

| Command | What it does |
| --- | --- |
| `socialtap search "<need or link>" [--platform <platform>] [--limit <n>]` | Find the endpoint for a need or a link (no key needed). |
| `socialtap endpoints [--platform <platform>] [--resource <resource>]` | Every endpoint: command, price and what it returns (no key needed). |
| `socialtap describe [<platform> [<endpoint>]]` | The CLI, a platform or an endpoint as JSON: params, price, output fields, exit codes (no key needed). |
| `socialtap jobs create <file\|-> \| get <id> \| wait <id> \| results <id> \| cancel <id> \| list` | Background jobs: many requests (or long walks) run for you; create, wait, read the results. |

### Account

| Command | What it does |
| --- | --- |
| `socialtap login [--non-interactive \| --complete] [--api-key -] [--name <key name>]` | Sign in with your browser and save an API key for this computer. |
| `socialtap logout [--no-revoke]` | Remove the saved key (a key the sign-in made is revoked too). |
| `socialtap whoami [--json]` | The account, balance and key in use, and where the key comes from. |
| `socialtap balance [--json]` | Your credit balance. |
| `socialtap usage [--since <since>] [--until <until>] [--bucket-width <1h\|1d>] [--group-by <group_by>] [--endpoint <endpoint>] [--api-key-id <api_key_id>] [--include <latency_histogram>] [--limit <integer>] [--cursor <cursor>]` | Requests and credits over time. |
| `socialtap webhooks list \| create --url <url> --events <type,…> [--description <text>] \| delete <id> \| test <id>` | Webhook endpoints: list, create, delete, send a test event. |
| `socialtap listen --forward-to <url> [--events <type,…>] [--print-secret]` | Forward your account's events to a local URL as signed webhook deliveries, for testing a receiver. |

### Agents

| Command | What it does |
| --- | --- |
| `socialtap tool [<name> [<json arguments> \| - \| @file]]` | The MCP server's tools, as an agent calls them (listed by toolset). |
| `socialtap mcp [--tools <toolset,…>] [--platforms <platform,…>]` | A local (stdio) MCP server that bridges to the remote one, signed in as the CLI is. |
| `socialtap init [--agent <id>[,<id>]...] [--project] [--default[=off]] [--dry-run] [--yes] [--status] [--uninstall] [--api-key <key>]` | Set up MCP clients and coding agents: the MCP server in each one's config, and the Agent Skill. |
| `socialtap uninstall [--agent <id>[,<id>]...] [--project] [--dry-run] [--yes]` | Remove what init added from every client (init --uninstall). |
| `socialtap skill` | Print the Agent Skill (SKILL.md) the site publishes. |

### Setup

| Command | What it does |
| --- | --- |
| `socialtap doctor [--json]` | Check Node, the config file, the key, the API, the balance, agents and the version. |
| `socialtap completion bash\|zsh\|fish` | Shell completion for bash, zsh or fish. |
| `socialtap open [<platform> [<endpoint>]]` | Open the docs: the home, a platform's page or an endpoint's (prints the link when no browser opens). |
| `socialtap version` | The CLI's version. |

## Global flags

They work anywhere on the line.

| Flag | Takes | What it does |
| --- | --- | --- |
| `--api-key` | `key` | API key, or - to read it from stdin. Prefer SOCIALTAP_API_KEY or socialtap login: other users can see a command line in the process list. |
| `--profile` | `name` | Config profile to use (default: default; or SOCIALTAP_PROFILE). |
| `--base-url` | `url` | API origin (default: https://socialtap.dev; or SOCIALTAP_BASE_URL). |
| `-H, --header` | `name:value` | Send this header too (repeatable). |
| `--timeout` | `seconds` | Timeout of one attempt, in seconds. |
| `--max-retries` | `n` | Retries of a retryable failure (0: none). |
| `--format` | `json\|jsonl\|table\|csv\|md` | Output format (default: a table or colored JSON at a terminal, JSON otherwise). |
| `--json` |  | Same as --format json. |
| `-o, --output` | `file` | Write the output to a file (its format from the extension); never over an existing file without --force. |
| `--force` |  | Let -o replace an existing file, and init replace a server of the same name that isn't this one. |
| `--jq` | `expr` | Filter the JSON with a jq expression (a subset: `socialtap help jq`). |
| `--concise` |  | Only the main fields, without nulls (a field left out is null). The default for coding agents. |
| `--full` |  | Every field (the default at a terminal and in scripts). |
| `--agent` | `auto\|yes\|no` | Agent mode: compact JSON, concise, no color, prompts or notices (default auto: detected from the environment; or SOCIALTAP_AGENT). |
| `--no-color` |  | No color (also NO_COLOR, TERM=dumb). |
| `-q, --quiet` |  | No receipts, hints or notices on stderr. |
| `--dry-run` |  | Print the request and its price, send nothing (no key needed). |
| `--idempotency-key` | `key` | Idempotency-Key for commands that create something. |
| `-h, --help` |  | Help for the command. |

## Batch, archive and file flags

Every endpoint command takes them. The file flags appear only on endpoints whose items have files.

| Flag | Takes | What it does |
| --- | --- | --- |
| `--input-file` | `file\|-` | One call per line: a link, handle or query, or a JSON object of params (# comments and blank lines skipped). Records come out in input order: {input, line, data \| error, credits_charged}. |
| `--concurrency` | `n` | Calls (or files) at once (default 4). |
| `--abort-on-error` |  | Stop a batch at its first failed line (default: every line runs). |
| `--resume` |  | Continue a batch that stopped: the lines it finished are printed again from its progress file, free, and the rest run. |
| `--state` | `file` | The batch's progress file (default: one in the CLI's state directory, named for the command, its flags and the input; written once the first request is sent, removed once every line is done). |
| `--job` |  | Run the batch as background jobs: no terminal to keep open, results read when they end. |
| `--archive` | `file` | Keep the IDs of items seen in this file (platform:id per line) and leave out the ones already in it. |
| `--break-on-existing` |  | With --archive and --all: stop the walk at the first item already in the archive (a newest-first list: what's new since the last run). |
| `--download` | `dir` | Save the items' files (videos, photos) under this directory (default: here). stdout lists each file; the data goes to -o. |
| `--name-template` | `template` | Where each file goes under --download: {field.path} of the item and {ext}, {name}, {index}, {date} (default {platform}/{id}-{name}.{ext}). |
| `--files` | `media\|cover\|avatar\|all` | Which files --download saves (comma-separated; default: the media, else every file the item has). |

## Exit codes

| Exit code | Meaning | API error codes |
| --- | --- | --- |
| `0` | Success. |  |
| `1` | Any other error. | `request_too_large`, `method_not_allowed`, `idempotency_key_reused`, `not_cached` |
| `2` | The command, a flag or a param is wrong (the CLI's check or the API's invalid_input): fix it, don't retry. | `invalid_input`, `invalid_cursor` |
| `3` | No API key, a key the API refuses, or not enough credits: sign in or add credits. | `unauthorized`, `forbidden`, `insufficient_credits`, `spend_limit_reached` |
| `4` | What you asked for doesn't exist or isn't public. | `endpoint_retired`, `job_not_found`, `unknown_endpoint`, `not_found`, `private_or_unavailable`, `no_transcript`, `no_live`, `no_media`, `no_readme`, `unavailable_for_legal_reasons` |
| `5` | Try again later: a rate limit, an upstream failure, a network error or a timeout. | `rate_limited`, `idempotency_key_in_progress`, `upstream_blocked`, `upstream_error`, `overloaded`, `internal` |
| `6` | A batch finished with some lines failed or not run, and the others done: each line's record says how it went. |  |
| `7` | The call succeeded and was charged, but --jq failed on its answer: the unfiltered JSON is on stdout. |  |

---

[HTML version](https://socialtap.dev/docs/cli/) · [Docs index for AI agents](https://socialtap.dev/llms.txt) · [All docs in one file](https://socialtap.dev/llms-full.txt)
