> For the complete documentation index, see [llms.txt](https://docs.nansen.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nansen.ai/api/trade.md).

# Trading

Choose between spot swaps and Hyperliquid perpetual trading. Nansen prepares unsigned transactions and you sign them locally.

Nansen's Trading API endpoints cover spot swaps and Hyperliquid perpetual trading. Both flows keep signing on your side: Nansen prepares unsigned transaction or action data, you sign locally, and you submit the signed payload.

## Choose a trading flow

| I want to...                                                          | Start here                                                            | Endpoint reference                                                                                                                                                                                                                                                                         |
| --------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Swap tokens on Solana or Base, including supported cross-chain routes | [Spot Trading](https://docs.nansen.ai/api/trade/spot-trading.md)      | [Quote](https://docs.nansen.ai/api/trade/spot-trading/quote.md), [Prepare](https://docs.nansen.ai/api/trade/spot-trading/prepare.md), [Execute](https://docs.nansen.ai/api/trade/spot-trading/execute.md), [Bridge Status](https://docs.nansen.ai/api/trade/spot-trading/bridge-status.md) |
| Open, manage or close Hyperliquid perpetual positions                 | [Perpetual Trading](https://docs.nansen.ai/api/trade/perp-trading.md) | [Perpetual Trading reference](https://docs.nansen.ai/api/trade/perp-trading/perpetual-trading-reference.md)                                                                                                                                                                                |

## Spot Trading

Use Spot Trading to quote and execute token swaps against onchain liquidity. It supports `solana` and `base`: same-chain swaps on either chain, and cross-chain swaps between the two.

The spot flow is:

1. [Quote](https://docs.nansen.ai/api/trade/spot-trading/quote.md) a swap route.
2. [Prepare](https://docs.nansen.ai/api/trade/spot-trading/prepare.md) the selected quote when a separate signable transaction is needed.
3. Sign locally.
4. [Execute](https://docs.nansen.ai/api/trade/spot-trading/execute.md) the signed transaction.
5. [Check bridge status](https://docs.nansen.ai/api/trade/spot-trading/bridge-status.md) for cross-chain routes.

Read the [Spot Trading guide](https://docs.nansen.ai/api/trade/spot-trading.md) for supported chains, amount units, signing details and availability.

## Perpetual Trading

Use Perpetual Trading to place orders, manage positions, move USDC between balances, and bridge funds for Hyperliquid perpetuals. The Hyperliquid bridge accepts deposits from Ethereum, Base, Arbitrum, Polygon and BNB Chain, and withdrawals to Ethereum, Base and Arbitrum. Orders carry a builder fee of 1 to 8 basis points, depending on your Nansen Points tier.

The perpetual trading flow is:

1. Prepare the action you want to take with its endpoint from the [Perpetual Trading reference](https://docs.nansen.ai/api/trade/perp-trading/perpetual-trading-reference.md).
2. Sign the returned typed data locally.
3. Submit the signed action with [Submit a signed perp action](https://docs.nansen.ai/api/trade/perp-trading/perpetual-trading-reference/perp-execute.md).

Read the [Perpetual Trading guide](https://docs.nansen.ai/api/trade/perp-trading.md) before placing orders. It covers builder-fee approval, funding, signing families, execution, error handling, costs and availability.

## Trading from the CLI or an AI agent

The [Nansen CLI](https://docs.nansen.ai/cli.md#trading) wraps both flows: `nansen trade` for spot swaps, `nansen perp` for Hyperliquid perpetuals and `nansen bridge` for moving USDC into and out of Hyperliquid. It signs with a wallet you set up in the CLI, and the Nansen API never receives a private key, so an AI agent can trade through it on your behalf. See [AI Agent Access](https://docs.nansen.ai/getting-started/agents.md#trading).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nansen.ai/api/trade.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
