# Tokens

The XSwap Tokens API returns token metadata for a given chain—or a single token if you supply its address.

***

### Endpoint

```http
GET https://xswap.link/api/tokens/v1
Content-Type: application/json
```

All query parameters are passed as a JSON payload in the `data` query parameter, URL-encoded.

***

### Request

#### Required Parameters

| Name           | Type      | Description                    |
| -------------- | --------- | ------------------------------ |
| `integratorId` | string    | Your registered integrator ID  |
| `chainIds`     | string\[] | Chain IDs (e.g. `["1", "56"]`) |

#### Optional Parameters

| Name        | Type      | Description                                                                                                                 |
| ----------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `ecosystem` | string    | <p></p><p>Filter by ecosystem (e.g. "EVM").</p><blockquote><p>Currently only <code>EVM</code> is supported</p></blockquote> |
| `addresses` | string\[] | Token contract addresses                                                                                                    |

***

### Response

| Field      | Type   | Description                            |
| ---------- | ------ | -------------------------------------- |
| `address`  | string | Token contract address                 |
| `symbol`   | string | Token symbol (e.g. `"ETH"`)            |
| `name`     | string | Token name (e.g. `"Ether"`)            |
| `decimals` | number | Number of decimals                     |
| `image`    | string | URL to token’s rounded 64x64 webp logo |

***

### Example Requests

```javascript
;(async () => {
  const payload = {
    integratorId: "xxx"
    chainId: "1"
  };

  const encoded = encodeURIComponent(JSON.stringify(payload));
  const url = `https://xswap.link/api/tokens/v1?data=${encoded}`;

  const res = await fetch(url, {
    method: "GET",
    headers: { "Content-Type": "application/json" },
  });
  const tokens = await res.json();
  console.log("All tokens for given chainId:", tokens);
})();
```

### Example Response

```json
[
    {
        "address": "0x0000000000000000000000000000000000000000",
        "symbol": "ETH",
        "decimals": 18,
        "name": "Ether",
        "image": "https://xswap.link/assets/tokens/1_0x0000000000000000000000000000000000000000_ETH.webp"
    },
    {
        "address": "0x8fe815417913a93ea99049fc0718ee1647a2a07c",
        "symbol": "XSWAP",
        "decimals": 18,
        "name": "XSWAP Token",
        "image": "https://xswap.link/assets/tokens/1_0x8fe815417913a93ea99049fc0718ee1647a2a07c_XSWAP.webp"
    },
    ...
]
```


---

# 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.xswap.link/xswap/xpay/api-v1-reference/tokens.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.
