<TradingAgentSetup />

Base URL:

```text
https://api.gum.ag/app/v1
```

For devnet, use `https://dev-api.gum.ag/app/v1`. Its OpenAPI spec is
`https://dev-api.gum.ag/app/v1/openapi.json`. Examples and the playground
use production.

## How a trade works

1. **Quote.** `POST /v1/swap/quote` with what you want to buy or sell. You get
   the price, the minimum you'll receive, and a `message` to sign.
2. **Sign.** Sign `message` with your wallet: Ed25519 for a Solana key,
   `personal_sign` for an EVM key. You send only the signature, and the API
   turns it into a GUM Network [typed signature](/protocol/typed-signatures). See
   [Sign with your wallet](/trading-api/signing).
3. **Submit.** `POST /v1/swap` with the quote's `transaction` and your
   `signature`. You get an `id`.
4. **Track.** Poll `GET /v1/swap/{id}`, or stream `/v1/swap/{id}/events`,
   until `final` is `true`. See [Track status](/trading-api/status).

Withdrawals follow the same steps with `/v1/withdraw/quote` and
`/v1/withdraw`. GUM Perps uses the same quote → sign → submit flow under
`/v1/perps/*`: margin deposits, withdrawals and leverage updates sign a GUM
Network transaction and settle on-chain (`status: "completed"`, `final: true`),
while Perps orders and cancels sign serialized action bytes (in Solana browser
wallets, sign the decoded `message` with
[`signMessage`](/trading-api/signing#perps-order-and-cancel-quotes) instead of
`signTransaction`) and return a matching-engine acknowledgement
(`status: "accepted"`, `final: false`; check `GET /v1/perps/accounts/{address}`
for live positions and open orders). A quote lasts about 30 seconds, so sign
and submit right away.

## Endpoints

### Spot & account

| Endpoint                                                                                   | What it does                              |
| ------------------------------------------------------------------------------------------ | ----------------------------------------- |
| [`GET /v1/tokens`](/trading-api/reference/get-tokens)                                     | Find tokens and stocks you can trade      |
| [`GET /v1/balances/{address}`](/trading-api/reference/get-balances)                       | Your USD and token balances               |
| [`GET /v1/deposit-addresses/{address}`](/trading-api/reference/get-deposit-addresses)     | Where to send funds, per chain            |
| [`GET /v1/history/{address}`](/trading-api/reference/get-history)                         | Deposits, swaps and withdrawals           |
| [`POST /v1/swap/quote`](/trading-api/reference/post-swap-quote)                           | Quote a buy or a sell                     |
| [`POST /v1/swap`](/trading-api/reference/post-swap)                                       | Submit a signed quote                     |
| [`GET /v1/swap/{id}`](/trading-api/reference/get-swap)                                    | A trade's status, polled or streamed      |
| [`POST /v1/withdraw/quote`](/trading-api/reference/post-withdraw-quote)                   | Quote a withdrawal                        |
| [`POST /v1/withdraw`](/trading-api/reference/post-withdraw)                               | Submit a signed withdrawal                |
| [`GET /v1/withdraw/{id}`](/trading-api/reference/get-withdraw)                            | A withdrawal's status, polled or streamed |
| [`GET /v1/chains`](/trading-api/reference/get-chains)                                     | Supported chains and their dollar tokens  |

### GUM Perps

| Endpoint                                                                                                   | What it does                                                |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [`GET /v1/perps/markets`](/trading-api/reference/get-perps-markets)                                       | Markets, live hourly & annualized funding, fees and tiers   |
| [`GET /v1/perps/markets/{symbol}/orderbook`](/trading-api/reference/get-perps-orderbook)                  | L2 orderbook bids and asks                                  |
| [`GET /v1/perps/markets/{symbol}/funding-history`](/trading-api/reference/get-perps-funding-history)      | Historical hourly funding rates and average APR             |
| [`GET /v1/perps/accounts/{address}`](/trading-api/reference/get-perps-account)                            | Sub-accounts, margin balances, open positions & open orders |
| [`POST /v1/perps/deposit/quote`](/trading-api/reference/post-perps-deposit-quote) / [`POST /v1/perps/deposit`](/trading-api/reference/post-perps-deposit) | Transfer USD from GUM spot into a Perps sub-account (free)  |
| [`POST /v1/perps/withdraw/quote`](/trading-api/reference/post-perps-withdraw-quote) / [`POST /v1/perps/withdraw`](/trading-api/reference/post-perps-withdraw) | Transfer free USD margin back to GUM spot (free)            |
| [`POST /v1/perps/leverage/quote`](/trading-api/reference/post-perps-leverage-quote) / [`POST /v1/perps/leverage`](/trading-api/reference/post-perps-leverage) | Set leverage for a market (cross or isolated)               |
| [`POST /v1/perps/orders/quote`](/trading-api/reference/post-perps-orders-quote) / [`POST /v1/perps/orders`](/trading-api/reference/post-perps-orders) | Quote and place market, limit or post-only Perps orders     |
| [`POST /v1/perps/orders/cancel/quote`](/trading-api/reference/post-perps-cancel-quote) / [`POST /v1/perps/orders/cancel`](/trading-api/reference/post-perps-cancel) | Cancel one open order or all open orders in a market        |

`GET /v1` lists them all, and `GET /v1/openapi.json` is the OpenAPI 3.1 spec.

## Conventions

- **Accounts.** `address` takes a Solana address or an EVM `0x` address, and
  each wallet is its own GUM account. Accounts that sign in with Google,
  Apple, X or a passkey can't trade through the API; use the GUM app for
  those.
- **Amounts** are decimal strings in whole units: `"25"` is $25 and `"0.5"` is
  half a token. The API never rounds an amount for you.
- **USD** is your GUM cash balance. Buys spend it and sells add to it.
- **Errors** always look like `{ "error": { "code", "message" } }`. Branch on
  `code`; see [Errors and limits](/trading-api/errors-and-limits).

## Strategy market data and portfolio tracking

Use `GET /v1/strategies/opportunities` for ranked cross-venue pairs and `GET /v1/strategies/funding-scanner` for current funding on individual markets. Both return `updatedAt` in milliseconds. The Single scanner returns GUM and Hyperliquid perpetuals. A missing quote or unmatched venue has a null value. Market reads are public.

`GET /v1/strategies/position-links` returns active tracking intervals for the signing account. Add `?includeArchived=true` to include earlier intervals. Each link identifies the GUM account, Hyperliquid hedge address, market, side and tracking dates. An interval alone cannot establish current fills or equity.

```bash
gumag strategies opportunities list
gumag strategies funding list
gumag strategies position-links list --include-archived
```

The CLI signs private reads locally. SDK callers use `getSignedHeaders` with `GET`, the exact `/v1/strategies/position-links` path including any query, and an empty body. Use the service path without the public gateway prefix `/app`. Send the returned `X-Signature`, `X-Signature-Type`, `X-Timestamp` and `X-Public-Key` headers within one minute.

<CardGroup cols={2}>
  <Card title="Quickstart" icon="terminal" href="/trading-api/quickstart">
    Quote, sign, submit and track in one short script.
  </Card>
  <Card title="Sign with your wallet" icon="code" href="/trading-api/signing">
    Solana and EVM keys, browser wallets, Python.
  </Card>
  <Card title="Track status" icon="trending-up" href="/trading-api/status">
    Poll, or stream live updates to a terminal, a page or React.
  </Card>
  <Card title="CLI" icon="terminal" href="/trading-api/cli">
    Trade from your terminal, or connect gumag to an MCP client.
  </Card>
</CardGroup>
