> For the complete documentation index, see [llms.txt](https://docs.xswap.link/xswap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xswap.link/xswap/xpay/api-v1-reference/tokens.md).

# 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"
    },
    ...
]
```
