# Command line

> The okdata command line, npx okdata: find endpoints from words, check prices, call with a spend cap, read the balance, set up MCP in Claude Code, Cursor or Codex.

Canonical page: https://okdata.online/docs/cli/

Find and call endpoints from a terminal, or let an agent that works in one do it.

```sh
npx okdata login                     # or install it: npm install -g okdata
npx okdata call douyin.videos.search 'query=露营装备' 'sort=latest'
```

Needs Node 20.3+. `okdata login` opens a link: check the 8-character code and approve, and this computer is linked to your account with a new key named "Command line", saved locally and never printed. Setting `OKDATA_API_KEY` works instead of logging in.

The second line is what the console [Playground](/console/playground/) prints in its command line tab: the endpoint id, then each parameter as `name=value` (quote values with spaces or Chinese). Lists are comma-separated (`ids=1,2,3`) or JSON (`ids=["1","2"]`).

## Commands

| Command | Cost | What it does |
| --- | --- | --- |
| `okdata find <words…>` | free, no key | Endpoints for plain words, English or 中文; a platform named in the words limits the search to it |
| `okdata show <id>` | free, no key | Parameters, price, paging, an example call and the docs link; `--lang zh` for Chinese |
| `okdata call <id> name=value…` | charged | One call. `--max-price 0.05` refuses (free) a call that could cost more; `--out items.jsonl` saves the items |
| `okdata call … --pages N --max-spend X` | charged | Follows up to N pages, stopping before the total could pass X dollars |
| `okdata more <request_id>` | free | A call's kept result again (24 h); `--receipt` shows the call record |
| `okdata balance` | free | Balance, this key's limits and the account's rate tier |
| `okdata run <plan.json>` | charged with `--yes` | A list of calls: prints the most it can cost, and runs within `--max-spend` only with `--yes` |
| `okdata login` | free | Links this computer to your account |
| `okdata setup --client claude-code` | free | Writes the okdata MCP entry into the client's config; also `cursor` and `codex`, several at once |

Every command takes `--json` (one JSON document on stdout, errors included) and `--help`. Without `--json`, a summary goes to stderr and the items to stdout, one JSON object per line, so `okdata call … | jq .text` works.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Done |
| 1 | A bad command, flag or parameter; nothing was sent |
| 2 | Refused and not charged; the error says why and whether to retry |
| 3 | Charged but failed or partial (a charged not_found, missing ids in a batch, pages stopped part way) |
| 4 | No key, or the key is invalid or disabled; run `okdata login` |
| 5 | Network: no answer from the API |

## Source

The command line is open source (MIT) on [GitHub](https://github.com/okdataapi/okdata); the npm package is `okdata`. To call okdata from code, use an [SDK](/docs/sdk/).

Updated 2026-11-13
