# Command line

The dataxapi command line has 8 commands: find, show, call, more, balance, run, login and setup. Finding and looking are free and need no key.

## Install

```bash
npm install -g dataxapi
```

Node 20 or later. It is one file with nothing else to install, and every request it makes goes through the TypeScript SDK. To run it without installing, put `npx dataxapi` in place of `dataxapi`: `npx dataxapi login`.

## Find, show, call

### 1. Find the endpoint

```bash
dataxapi find "tiktok video search"
```

Free, no key. When nothing matches it says so and does not fill the list with near misses.

### 2. Show its contract and price

```bash
dataxapi show tiktok.videos.search
```

Free, no key. Several IDs can be given at once.

### 3. Call it

```bash
dataxapi call tiktok.videos.search 'query=space station' --max-price 0.002
```

Needs a key; costs $0.0020 a call. With `--max-price`, a call that could cost more is refused before it runs. The first line printed says how many items came back, what was charged, the balance, and the command for the next page.

## Commands

| Command | Needs a key? | Charged? | What it does |
| --- | --- | --- | --- |
| `find <words...>` | No | No | Finds the endpoint for a need put in words, in English or Chinese: 5 at most, each with what it needs, its price and a call ready to run. `--platform` and `--category` narrow it. |
| `show <capability> [<capability> ...]` | No | No | One or more endpoints' whole contract: parameters, fields, paging, the price and the most one call can cost, whether it is up now. |
| `call <capability> [name=value ...]` | Yes | Yes | Fetches one page. Parameters are `name=value`; a list is comma-separated (`ids=1,2`). |
| `more <id>` | Yes | No | What became of a call and what it was charged; the rest of a result that was cut to fit, or the same result in another view. By the result ID `call` printed, or the request ID an error named. |
| `balance` | Yes | No | The balance, this key's limits and what it has spent, the rate limit. |
| `run <task> [name=value ...]` | Yes | Yes | Runs a task step by step. It first shows the most calls and the most money and asks; `--plan` only shows that, with no key and no charge. |
| `login` | No | No | Links this machine to your account: prints a link and a check code, waits for you to approve in a browser where you are signed in, and saves a key made for the command line. |
| `setup` | No | No | Writes the MCP entry and the base skill for the coding agents on this machine. |

Every command takes `--help`.

## The key, the output, paging

- `DATAXAPI_API_KEY`: Where the key is read from. Failing that, from the configuration file `~/.config/dataxapi/config.json`, where `dataxapi login` saves one. The key is never printed.
- `--json`: Prints the service's answer as JSON, errors too. Without it the output is text for a person or an agent: a summary line, then an item a line in the compact view, about 20 KB at most; `dataxapi more <id>` reads the rest for free.
- `--out <file>`: Writes the whole answer to a file and prints only the summary line.
- `--pages <n>`: Walks up to n pages, each a call charged on its own.
- `--max-spend <usd>`: With `--pages`: stops before a page that could take the total past this many dollars.
- `--idempotency-key <key>`: The command line makes a key for every call by itself and prints it when the answer was lost; send the call again with it and it is the same call, not charged twice.

```bash
dataxapi call tiktok.videos.search 'query=space station' --pages 3 --max-spend 0.006 --out page.json
```

## Exit codes

One meaning a code, so a script or an agent knows what to do next without reading the text.

| Code | Meaning | What next |
| --- | --- | --- |
| 0 | Done. |  |
| 1 | The command line itself failed. | A charge is only what was already printed. |
| 2 | Refused before anything ran; not charged. Wrong usage, no key, a parameter, the price cap, the balance, a limit. | Change the request; do not send it again as it is. |
| 3 | It ran and failed; not charged. | The message says whether to retry. Never retry `not_found`. |
| 4 | Not known whether it was charged: the call may have run. | Look it up with `dataxapi more <id>`, or send it again under the same `--idempotency-key`. |
| 5 | A task stopped before its end: at its budget, expired, or at a step that failed. | The bill says what was charged; `--resume` goes on without charging it again. |

## Set up your coding agents

```bash
dataxapi setup
dataxapi setup --client claude-code,cursor
```

`dataxapi setup` writes two things for each of Claude Code, Codex, Cursor: the [MCP](https://dataxapi.com/docs/mcp/) entry, and a base skill that teaches the agent to find, price and call. Without `--client` it sets up the ones it finds on this machine. What was in those files stays; only our own entry is replaced.

> No key is written: the entries read `DATAXAPI_API_KEY` from the agent's environment. Only a key that `dataxapi login` saved, which no environment variable holds, is written into them, and only when you say `--write-key`.

---

Catalog revision c48ce454ae6c4c65. [HTML version](https://dataxapi.com/docs/cli/)
