> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tradingapi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Trading API

> The exchange for AI agents. Trade crypto, stocks, commodities and more through the API or MCP.

Trading API is an exchange for AI agents. Sign up, get a key, and trade crypto, stocks, commodities and more through the API or MCP.

Each order takes a market, a side and an amount in US dollars. We work out the size, place the order and tell you how it went.

```bash theme={"system"}
curl https://tradingapi.dev/v1/orders \
  -H "Authorization: Bearer $TRADINGAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "client_order_id": "my-first-order",
    "market": "BTC",
    "side": "buy",
    "type": "market",
    "value": "25.00"
  }'
```

The response is the finished order. Here are its main fields:

```json theme={"system"}
{
  "object": "order",
  "status": "filled",
  "size": "0.00029",
  "average_fill_price": "84012.4",
  "filled_value": "24.363596",
  "summary": "Bought 0.00029 BTC for $24.36 at an average of $84,012.40 in 1 fill, fee $0.0353. You asked for $25.00; the order was sized so it could not cost more even at its price limit of $84,430. It left you long 0.00029 BTC."
}
```

> [!WARNING]
>
> Every order trades real money, and there is no test mode. Start with small amounts and an API key with low limits.

## Designed for agents

> **[Limits you set](https://docs.tradingapi.dev/concepts/api-keys.md)**
>
> Each key has its own markets, largest order and 24-hour limit. No key can withdraw money, and an agent can't change its own limits.

> **[Amounts in dollars](https://docs.tradingapi.dev/concepts/orders.md#value-and-size)**
>
> Orders are sized in US dollars, with no leverage, on markets with plain names like `BTC` and `TSLA`. We work out the size, so a buy never costs more than you asked.

> **[Safe retries](https://docs.tradingapi.dev/guides/retries.md)**
>
> Sending the same request with the same `client_order_id` never places a second order, so an agent can retry after any timeout.

> **[Answers it can act on](https://docs.tradingapi.dev/guides/errors.md)**
>
> Every error has a `hint` with a fix and says whether retrying can help. Every order has a short `summary` to pass on to the user.

## What you can do

* Browse and search markets, from crypto such as BTC and ETH to real-world assets such as TSLA.
* Place market orders, and limit orders that fill right away at your price or better.
* Preview an order to see the fill, the fees and the position you'd end up with.
* Read your positions and close them, in full or in part.
* Read your balance, fills and withdrawals.

Every position is 1×. You pay the full value of what you buy, and nothing is borrowed.

## Next steps

> **[Quickstart](https://docs.tradingapi.dev/quickstart.md)**
>
> Fund your account, create a key and place your first order.

> **[How orders work](https://docs.tradingapi.dev/concepts/orders.md)**
>
> How orders are sized, what each status means, and every field.

> **[Build with AI agents](https://docs.tradingapi.dev/guides/agents.md)**
>
> Give an agent a key with tight limits and let it trade.

> **[API reference](https://docs.tradingapi.dev/api-reference/introduction.md)**
>
> Every endpoint, field and error code.

## Under the hood

You fund your account by sending USDC on Arbitrum, and it's ready to trade within a few minutes. Orders are executed on [Hyperliquid](https://hyperliquid.xyz), where your balance is held as USDC in a wallet we create for your account, so you don't need a Hyperliquid account of your own. The fee on each fill includes both Hyperliquid's fee and ours. To withdraw, you use the account page and sign the withdrawal yourself.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.