# Markets

## Get List of Markets

* **Method**: GET
* **Endpoint**: `/api/v1/crypto/markets`
* **Headers**:
  * `Cookie`: The session cookie value.
  * `csrf_token`: The CSRF token obtained after login.
* **Query**:
  * `offset`: (integer) Pagination offset.
  * `limit`: (integer) Number of records to return.
  * `exchangeNames[]`: (array) List of exchange names.
    * e.g. exchangeNames\[]=OKX\&exchangeNames\[]=Kraken
  * `tokenSymbols`: (string) Token symbol (e.g. BTC).
  * `active`: (boolean) Specifies wether the tokens should be active.

**Description:**

The **/api/v1/crypto/markets** endpoint with a GET method is designed to provide a comprehensive list of cryptocurrency markets available across various exchanges. It supports a range of query parameters to tailor the response according to specific needs, such as pagination through offset and limit, filtering by exchangeNames\[] to include markets from specific exchanges, specifying tokenSymbols to filter markets by the trading pairs involving a particular token, and determining whether the market collector should be active.

**Example with curl:**

```bash
curl -X GET "http://example.com/api/v1/crypto/markets?offset=0&limit=5&exchangeNames[]=Binance&tokenSymbols=BTC&active=true" \
     -H "Cookie: session_cookie_value"  \
     -H "csrf_token: your_csrf_token_here"
```

**Example Response Payload:**

```json
{
    "data": [
        {
            "id": 5,
            "externalMarketId": "BTCEUR",
            "baseId": 6,
            "quoteId": 8,
            "exchangeId": 4,
            "meta": null,
            "baseMeta": null,
            "quoteMeta": null,
            "description": null,
            "imageUrl": "http://example.com/ccdb-reference/Markets/5",
            "active": true,
            "exchange": {
                "id": 4,
                "externalExchangeId": "bitfinex",
                "dataSource": "bitfinex",
                "type": "CEX",
                "name": "Bitfinex",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:08:54.450Z",
                "updatedAt": "2024-02-09T00:08:54.450Z"
            },
            "baseToken": {
                "id": 6,
                "symbol": "BTC",
                "name": null,
                "itin": "DXVP-YDQC-3",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:09:06.725Z",
                "updatedAt": "2024-02-16T09:57:11.997Z"
            },
            "quoteToken": {
                "id": 8,
                "symbol": "EUR",
                "name": null,
                "itin": null,
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:09:06.742Z",
                "updatedAt": "2024-02-09T00:09:06.742Z"
            },
            "createdAt": "2024-02-09T00:09:06.744Z",
            "updatedAt": "2024-02-20T12:59:39.574Z"
        },
        {
            "id": 4,
            "externalMarketId": "BTCUSD",
            "baseId": 6,
            "quoteId": 7,
            "exchangeId": 4,
            "meta": null,
            "baseMeta": null,
            "quoteMeta": null,
            "description": "test",
            "imageUrl": null,
            "active": true,
            "exchange": {
                "id": 4,
                "externalExchangeId": "bitfinex",
                "dataSource": "bitfinex",
                "type": "CEX",
                "name": "Bitfinex",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:08:54.450Z",
                "updatedAt": "2024-02-09T00:08:54.450Z"
            },
            "baseToken": {
                "id": 6,
                "symbol": "BTC",
                "name": null,
                "itin": "DXVP-YDQC-3",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:09:06.725Z",
                "updatedAt": "2024-02-16T09:57:11.997Z"
            },
            "quoteToken": {
                "id": 7,
                "symbol": "USD",
                "name": null,
                "itin": null,
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:09:06.729Z",
                "updatedAt": "2024-02-09T00:09:06.729Z"
            },
            "createdAt": "2024-02-09T00:09:06.732Z",
            "updatedAt": "2024-02-11T14:52:36.356Z"
        },
        {
            "id": 7,
            "externalMarketId": "BTCUSDT",
            "baseId": 6,
            "quoteId": 9,
            "exchangeId": 4,
            "meta": {
                "test": 1
            },
            "baseMeta": null,
            "quoteMeta": null,
            "description": "test",
            "imageUrl": null,
            "active": true,
            "exchange": {
                "id": 4,
                "externalExchangeId": "bitfinex",
                "dataSource": "bitfinex",
                "type": "CEX",
                "name": "Bitfinex",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:08:54.450Z",
                "updatedAt": "2024-02-09T00:08:54.450Z"
            },
            "baseToken": {
                "id": 6,
                "symbol": "BTC",
                "name": null,
                "itin": "DXVP-YDQC-3",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:09:06.725Z",
                "updatedAt": "2024-02-16T09:57:11.997Z"
            },
            "quoteToken": {
                "id": 9,
                "symbol": "USDT",
                "name": "USD Token",
                "itin": null,
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-11T14:37:35.216Z",
                "updatedAt": "2024-02-11T14:37:35.216Z"
            },
            "createdAt": "2024-02-11T14:41:14.838Z",
            "updatedAt": "2024-02-13T15:21:24.979Z"
        },
        {
            "id": 9,
            "externalMarketId": "ETHUSDT",
            "baseId": 10,
            "quoteId": 9,
            "exchangeId": 4,
            "meta": null,
            "baseMeta": null,
            "quoteMeta": null,
            "description": null,
            "imageUrl": null,
            "active": true,
            "exchange": {
                "id": 4,
                "externalExchangeId": "bitfinex",
                "dataSource": "bitfinex",
                "type": "CEX",
                "name": "Bitfinex",
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-09T00:08:54.450Z",
                "updatedAt": "2024-02-09T00:08:54.450Z"
            },
            "baseToken": {
                "id": 10,
                "symbol": "ETH",
                "name": "Ethereum",
                "itin": null,
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-13T13:48:55.485Z",
                "updatedAt": "2024-02-13T13:48:55.485Z"
            },
            "quoteToken": {
                "id": 9,
                "symbol": "USDT",
                "name": "USD Token",
                "itin": null,
                "description": null,
                "imageUrl": null,
                "createdAt": "2024-02-11T14:37:35.216Z",
                "updatedAt": "2024-02-11T14:37:35.216Z"
            },
            "createdAt": "2024-02-13T15:22:40.255Z",
            "updatedAt": "2024-02-13T15:22:40.255Z"
        }
    ],
    "meta": {
        "fetchCount": 4,
        "totalCount": 4
    },
    "status": 1
}
```

## Get Market

* **Method**: GET
* **Endpoint**: `/api/v1/crypto/markets/:id`
* **Headers**:
  * `Cookie`: The session cookie value.
  * `csrf_token`: The CSRF token obtained after login.
* **Parameters**:
  * `id`: (integer) Market identifier in the database.

**Description:**

The **/api/v1/crypto/markets/:id** endpoint is used to retrieve detailed information about a specific cryptocurrency market, identified by its id in the database. This GET request provides comprehensive details of the market, including its internal and external identifiers, information about the base and quote tokens (such as their IDs), the exchange on which the market is listed, and other metadata like description and image URL. Additionally, it indicates whether the market is currently active and includes timestamps for when the market was created and last updated.

**Example with curl:**

```bash
curl -X GET "http://example.com/api/v1/crypto/markets/5" \
     -H "Cookie: session_cookie_value"  \
     -H "csrf_token: your_csrf_token_here"
```

**Example Response Payload:**

```json
{
    "data": {
        "id": 5,
        "externalMarketId": "BTCEUR",
        "baseId": 6,
        "quoteId": 8,
        "exchangeId": 4,
        "meta": null,
        "baseMeta": null,
        "quoteMeta": null,
        "description": null,
        "imageUrl": "http://example.com/ccdb-reference/Markets/5",
        "active": true,
        "createdAt": "2024-02-09T00:09:06.744Z",
        "updatedAt": "2024-02-20T12:59:39.574Z"
    },
    "status": 1
}
```


---

# 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-ccdb.waexservices.com/echofeed/api-documentation/markets.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.
