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

# Manage Your Coinbase Advanced Trade Portfolio via API

> Fetch account balances, view open orders, cancel orders, and track your Coinbase portfolio performance using the Advanced Trade API.

The Coinbase Advanced Trade API gives you complete visibility into your portfolio and full control over your open positions. You can query account balances across all currencies, enumerate your working orders, cancel one or many orders in a single request, and retrieve a breakdown of your entire portfolio by asset. This guide walks you through each of these workflows with practical code examples in curl and Python.

## View your account balances

Call `GET /api/v3/brokerage/accounts` to list all accounts associated with your profile, including the available and hold balances for each currency.

```bash curl theme={null}
curl -X GET "https://api.coinbase.com/api/v3/brokerage/accounts" \
  -H "Authorization: Bearer $JWT"
```

```python Python theme={null}
import requests

url = "https://api.coinbase.com/api/v3/brokerage/accounts"
headers = {"Authorization": f"Bearer {JWT}"}

response = requests.get(url, headers=headers)
accounts = response.json().get("accounts", [])

for account in accounts:
    print(
        account["currency"],
        "Available:", account["available_balance"]["value"],
        "Hold:", account["hold"]["value"],
    )
```

**Example response:**

```json theme={null}
{
  "accounts": [
    {
      "uuid": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "BTC Wallet",
      "currency": "BTC",
      "available_balance": {
        "value": "0.12345678",
        "currency": "BTC"
      },
      "hold": {
        "value": "0.00100000",
        "currency": "BTC"
      },
      "type": "ACCOUNT_TYPE_CRYPTO",
      "active": true
    },
    {
      "uuid": "a1b2c3d4-0001-0001-0001-000000000002",
      "name": "USD Wallet",
      "currency": "USD",
      "available_balance": {
        "value": "1500.00",
        "currency": "USD"
      },
      "hold": {
        "value": "0.00",
        "currency": "USD"
      },
      "type": "ACCOUNT_TYPE_FIAT",
      "active": true
    }
  ],
  "has_next": false,
  "cursor": "",
  "size": 2
}
```

The `available_balance` reflects funds you can use immediately; `hold` represents funds reserved by open orders.

## List your open orders

To see all orders that are currently working on the book, call `GET /api/v3/brokerage/orders/historical/batch` with the `order_status=OPEN` query parameter.

```bash curl theme={null}
curl -X GET \
  "https://api.coinbase.com/api/v3/brokerage/orders/historical/batch?order_status=OPEN" \
  -H "Authorization: Bearer $JWT"
```

```python Python theme={null}
import requests

url = "https://api.coinbase.com/api/v3/brokerage/orders/historical/batch"
headers = {"Authorization": f"Bearer {JWT}"}
params = {"order_status": "OPEN"}

response = requests.get(url, headers=headers, params=params)
orders = response.json().get("orders", [])

for order in orders:
    print(
        order["order_id"],
        order["product_id"],
        order["side"],
        "filled:", order["filled_size"],
    )
```

**Example response:**

```json theme={null}
{
  "orders": [
    {
      "order_id": "b2c3d4e5-0002-0002-0002-000000000001",
      "client_order_id": "limit-sell-001",
      "product_id": "BTC-USD",
      "side": "SELL",
      "status": "OPEN",
      "time_in_force": "GOOD_UNTIL_CANCELLED",
      "created_time": "2024-01-20T10:00:00Z",
      "filled_size": "0",
      "average_filled_price": "0",
      "order_configuration": {
        "limit_limit_gtc": {
          "base_size": "0.001",
          "limit_price": "70000",
          "post_only": false
        }
      }
    }
  ],
  "has_next": false,
  "cursor": ""
}
```

You can also filter by `product_id`, `order_type`, or a time range using the `start_date` and `end_date` query parameters.

## Cancel an order

To cancel one or more open orders, send a `POST` request to `/api/v3/brokerage/orders/batch_cancel` with an array of `order_ids`. You can cancel up to 100 orders in a single call.

```bash curl theme={null}
curl -X POST \
  "https://api.coinbase.com/api/v3/brokerage/orders/batch_cancel" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "order_ids": ["order-uuid-1", "order-uuid-2"]
  }'
```

```python Python theme={null}
import requests

url = "https://api.coinbase.com/api/v3/brokerage/orders/batch_cancel"
headers = {
    "Authorization": f"Bearer {JWT}",
    "Content-Type": "application/json",
}
payload = {
    "order_ids": ["order-uuid-1", "order-uuid-2"]
}

response = requests.post(url, headers=headers, json=payload)
results = response.json().get("results", [])

for result in results:
    status = "cancelled" if result["success"] else f"failed: {result['failure_reason']}"
    print(result["order_id"], "->", status)
```

**Example response:**

```json theme={null}
{
  "results": [
    {
      "success": true,
      "failure_reason": "",
      "order_id": "order-uuid-1"
    },
    {
      "success": false,
      "failure_reason": "UNKNOWN_CANCEL_ORDER",
      "order_id": "order-uuid-2"
    }
  ]
}
```

The response includes a result entry for every `order_id` you submitted. Check each `success` field individually — a partial failure does not cause the whole request to fail.

## View portfolio breakdown

To see how your assets are distributed across positions, call `GET /api/v3/brokerage/portfolios/{portfolio_uuid}`. This returns a snapshot of your portfolio including the value and cost basis of each position.

> [!TIP]
>
> You can retrieve your portfolio UUIDs by first calling `GET /api/v3/brokerage/portfolios`, which returns a list of all portfolios on your account. Use the `uuid` field from that response in the path below.

```bash curl theme={null}
curl -X GET \
  "https://api.coinbase.com/api/v3/brokerage/portfolios/{portfolio_uuid}" \
  -H "Authorization: Bearer $JWT"
```

```python Python theme={null}
import requests

portfolio_uuid = "your-portfolio-uuid"
url = f"https://api.coinbase.com/api/v3/brokerage/portfolios/{portfolio_uuid}"
headers = {"Authorization": f"Bearer {JWT}"}

response = requests.get(url, headers=headers)
breakdown = response.json().get("breakdown", {})

positions = breakdown.get("spot_positions", [])
for pos in positions:
    print(
        pos["asset"],
        "Total:", pos["total_balance_fiat"],
        "Cost basis:", pos["cost_basis"]["value"],
    )
```

**Example response:**

```json theme={null}
{
  "breakdown": {
    "portfolio": {
      "uuid": "your-portfolio-uuid",
      "name": "Default Portfolio",
      "type": "DEFAULT"
    },
    "portfolio_balances": {
      "total_balance": { "value": "15432.87", "currency": "USD" },
      "total_unrealized_pnl": { "value": "1234.50", "currency": "USD" }
    },
    "spot_positions": [
      {
        "asset": "BTC",
        "account_uuid": "a1b2c3d4-0001-0001-0001-000000000001",
        "total_balance_fiat": "14000.00",
        "total_balance_crypto": "0.21500000",
        "available_to_trade_fiat": "14000.00",
        "cost_basis": {
          "value": "12765.50",
          "currency": "USD"
        },
        "unrealized_pnl": "1234.50",
        "percent_change_24h": "2.45"
      },
      {
        "asset": "USD",
        "account_uuid": "a1b2c3d4-0001-0001-0001-000000000002",
        "total_balance_fiat": "1432.87",
        "total_balance_crypto": "1432.87",
        "available_to_trade_fiat": "1432.87",
        "cost_basis": {
          "value": "1432.87",
          "currency": "USD"
        },
        "unrealized_pnl": "0",
        "percent_change_24h": "0"
      }
    ]
  }
}
```

## Get transaction summary

The transaction summary endpoint provides an aggregated overview of your trading fees and volume over a specified time window. This is useful for auditing costs or calculating net P\&L.

```bash curl theme={null}
curl -X GET \
  "https://api.coinbase.com/api/v3/brokerage/transaction_summary?product_type=SPOT" \
  -H "Authorization: Bearer $JWT"
```

```python Python theme={null}
import requests

url = "https://api.coinbase.com/api/v3/brokerage/transaction_summary"
headers = {"Authorization": f"Bearer {JWT}"}
params = {
    "product_type": "SPOT",
    # Optional: narrow the time window
    # "start_date": "2024-01-01T00:00:00Z",
    # "end_date": "2024-01-31T23:59:59Z",
}

response = requests.get(url, headers=headers, params=params)
summary = response.json()

print("Total volume:", summary.get("total_volume"))
print("Total fees:", summary.get("total_fees"))
print("Fee tier:", summary.get("fee_tier", {}).get("pricing_tier"))
```

**Example response:**

```json theme={null}
{
  "total_volume": 48320.75,
  "total_trades": 37,
  "total_fees": 72.48,
  "fee_tier": {
    "pricing_tier": "Advanced 1",
    "usd_from": "0",
    "usd_to": "10000",
    "taker_fee_rate": "0.006",
    "maker_fee_rate": "0.002"
  },
  "goods_and_services_tax": {
    "rate": "0",
    "type": "INCLUSIVE"
  },
  "advanced_trade_only_volume": 48320.75,
  "advanced_trade_only_fees": 72.48
}
```

The `fee_tier` block shows your current maker/taker fee rates based on your 30-day trading volume. Higher volume unlocks lower fee tiers automatically.


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