# Discovery: chains, tokens, and pairs

Use the discovery endpoints to fetch supported chains, tokens, and tradeable pairs before building quote requests.

## Step 0: Health check (optional)

Verify the gateway is up with `GET /health` (no auth required). See [Health Check](/health-check.md).

## Step 1: List chains

Get all enabled chains to build chain selectors or validate `fromChain` / `toChain`.

```bash
curl -X GET 'https://api.gateway.zert.com/api/v1/chains' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

Response:

```json
{
  "data": {
    "chains": [
      { "id": "eth-mainnet", "name": "Ethereum Mainnet" },
      { "id": "polygon-mainnet", "name": "Polygon" }
    ]
  },
  "meta": { "requestId": "...", "timestamp": "..." }
}
```

Use `id` values as chain identifiers in quote and status calls.

## Step 2: List tokens (optional)

Filter tokens by chain or search by symbol/name. Use results to build token selectors and validate token availability.

```bash
# All tokens on Ethereum, limit 20
curl -X GET 'https://api.gateway.zert.com/api/v1/tokens?chainRef=eth-mainnet&limit=20' \
  -H 'Authorization: Bearer YOUR_API_KEY'

# Search by symbol
curl -X GET 'https://api.gateway.zert.com/api/v1/tokens?q=USDC&limit=50' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

Response includes `data.tokens` with fields like `chain`, `symbol`, `name`, `address`, `decimals`, and an optional `nextCursor`.

## Step 3: List pairs (optional)

Get tradeable pairs for a chain or token to validate or suggest quote inputs.

```bash
# Pairs on Ethereum with USDC as input
curl -X GET 'https://api.gateway.zert.com/api/v1/pairs?chainRef=eth-mainnet&tokenIn=USDC&limit=50' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

Response includes `data.pairs` with `fromChain`, `toChain`, `tokenIn`, `tokenOut`, and an optional `nextCursor`.

## Step 4: Request a quote

Use discovered chain identifiers and token identifiers in `POST /quote`:

```bash
curl -X POST 'https://api.gateway.zert.com/api/v1/quote' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
    "fromChain": "solana",
    "toChain": "avax",
    "tokenIn": "SOL",
    "tokenOut": "WETH",
    "network": "mainnet",
    "amount": "100.00"
  }'
```

## Summary

| Step | Endpoint      | Purpose                                  |
| ---- | ------------- | ---------------------------------------- |
| 0    | `GET /health` | Optional health check (no auth)          |
| 1    | `GET /chains` | Get supported chain identifiers          |
| 2    | `GET /tokens` | Get tokens by chain or search            |
| 3    | `GET /pairs`  | Get tradeable pairs for validation or UX |
| 4    | `POST /quote` | Get route summaries for a swap idea      |

See [Health Check](/health-check.md), [List Chains](/api-reference/discovery/list-chains.md), [List Tokens](/api-reference/discovery/list-tokens.md), [List Pairs](/api-reference/discovery/list-pairs.md), and [Request Quote](/api-reference/swap/request-quote.md) for full parameters and responses.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zert.com/integration-example/discovery-and-quote.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
