# For agents

> Hand the whole API to an LLM or agent in one line.

Everything an agent needs is a URL away. Pick the one that fits the client.

| Need                          | URL                                                                    |
| ----------------------------- | ---------------------------------------------------------------------- |
| Docs, short index             | `https://xdataapi.io/llms.txt`                                         |
| Docs, everything in one file  | `https://xdataapi.io/llms-full.txt`                                    |
| One docs page as Markdown     | add `.md` to its URL, for example `https://xdataapi.io/docs/search.md` |
| Contract, OpenAPI 3.1         | `https://api.xdataapi.io/openapi.yaml`                                 |
| Tools, MCP server             | `https://api.xdataapi.io/mcp` (signs itself in, or header `x-api-key`) |
| Live health, JSON             | `https://api.xdataapi.io/status`                                       |
| Directory of all of the above | `https://api.xdataapi.io/`                                             |

Every docs page also answers a request with `Accept: text/markdown` in Markdown.

## Prompt to paste [#prompt-to-paste]

```text
Use the xdataapi.io API to read public X (Twitter) data. Docs: https://xdataapi.io/llms-full.txt
Base URL https://api.xdataapi.io, header x-api-key: xd_live_... Every response has credits_charged and
balance_remaining; stop when balance_remaining is 0. Errors are JSON with a stable "code" field.
Pages return next_cursor; pass it back as cursor.
```

## MCP in one line [#mcp-in-one-line]

```bash
claude mcp add --transport http xdataapi https://api.xdataapi.io/mcp
```

No key in it: the server signs the client in through a browser and it gets its own credential. Other
clients, and the header form for a machine with no browser: see [MCP server](/docs/mcp). The 14 tools are
read-only and annotated as such, so clients that auto-approve read-only tools do not prompt on every call.

## Why the API is easy for agents [#why-the-api-is-easy-for-agents]

* **Flat objects.** A `Tweet` and a `User` are the same shape on every endpoint. No nested `legacy` or `result` wrappers.
* **Stable error codes.** `no_credits`, `not_found`, `rate_limited`, `access_denied`, `upstream_error`. The
  [errors page](/docs/errors) says what to do for each. Failed requests cost nothing.
* **Costs in the response.** `credits_charged` and `balance_remaining` on every call, so an agent can budget without
  a second request.
* **Cursors, not page numbers.** `next_cursor` is opaque; pass it back as `cursor`. No cursor means the end.
* **Batch.** Up to 100 handles or ids in one call, one charge, errors per item. See [batch](/docs/batch).
* **Idempotent reads.** Everything is a read. Retrying is always safe; a repeat inside the cache window costs half.
* **A key per agent.** Make one key per agent in the [dashboard](https://xdataapi.io/dashboard) so one can be revoked alone.
