> For the complete documentation index, see [llms.txt](https://doc.mal.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.mal.io/en/mal.io-open-api-docs-coingecko.md).

# Mal.io Open API Docs (CoinGecko)

***All the following endpoints are public and no authentication is required to fetch data from them.***

***

## Host

```
https://openapi.malresource.com
```

***

## Endpoints (CoinGecko)

### Tickers

```
GET /api/v1/cg/tickers
```

#### **Description**

This endpoint provides the last 24-hour pricing and volume information on each market pair available on Mal.io.

#### **Request Parameters**

None

#### Request Example

```bash
curl -X GET https://${host}/api/v1/cg/tickers
```

#### Response Data Example

```json
[
  {
    "ask": "59123.89",
    "base_currency": "BTC",
    "base_volume": "53.60800",
    "bid": "59123.88",
    "high": "59817.75",
    "last_price": "59123.88",
    "low": "57526.31",
    "target_currency": "USDT",
    "target_volume": "3140989.30",
    "ticker_id": "BTC_USDT"
  },
  {
    "ask": "2597.99",
    "base_currency": "ETH",
    "base_volume": "637.0985",
    "bid": "2597.98",
    "high": "2630.88",
    "last_price": "2597.98",
    "low": "2550.44",
    "target_currency": "USDT",
    "target_volume": "1656152.93",
    "ticker_id": "ETH_USDT"
  }
]
```

### Order Book

```
GET /api/v1/cg/orderbook/${pair_symbol}
```

#### Description

This endpoint provides order book information with a minimum depth of 100 (50 each side).

#### Request Parameters

<table><thead><tr><th>Name</th><th width="126">Type</th><th width="120">Mandatory</th><th>Meta</th></tr></thead><tbody><tr><td>depth</td><td>INT</td><td>No</td><td>Min: 100, Default: 100</td></tr></tbody></table>

#### Request Example

```bash
curl -X GET https://${host}/api/v1/cg/orderbook/btc_usdt?depth=500
```

#### Response Data  Example

```json
{
  "asks": [
    [
      "59020.0",
      "0.08129799"
    ],
    [
      "59020.01",
      "0.01871799"
    ]
  ],
  "bids": [
    [
      "59019.99",
      "3.61231499"
    ],
    [
      "59019.76",
      "0.01420299"
    ]
  ],
  "ticker_id": "BTC_USDT",
  "timestamp": "1723866167"
}
```

### Historical Trades

```
GET api/v1/cg/trades/history/${pair_symbol}?side=sell
```

#### Description

This endpoint provides historical completed trades for a given market pair.

#### Request Parameters

<table><thead><tr><th>Name</th><th width="99">Type</th><th width="120">Mandatory</th><th>Meta</th></tr></thead><tbody><tr><td>side</td><td>STRING</td><td>YES</td><td>The nature of trade - buy/sell</td></tr><tr><td>limit</td><td>INT</td><td>NO</td><td>Default: 100; max 1000</td></tr><tr><td>start_time</td><td>STRING</td><td>NO</td><td>Start time from which to query historical trades from. Must be in the format of: <code>YYYY-MM-DDDD</code>; e.g.: <code>2019-08-07</code></td></tr><tr><td>end_time</td><td>STRING</td><td>NO</td><td>End time from which to query historical trades from. Must be in the format of: <code>YYYY-MM-DDDD</code>; e.g.: <code>2019-08-07</code></td></tr></tbody></table>

#### Request Example

```bash
curl -X GET https://${host}/api/v1/cg/trades/history/btc_usdt?side=sell&limit=2&start_time=2022-05-02
```

#### Response Data Example

```json
{
  "buy": [],
  "sell": [
    {
      "base_volume": "0.0000",
      "price": "59216.7400",
      "target_volume": "0.5922",
      "trade_id": 293655137,
      "trade_timestamp": "1723870785",
      "type": "sell"
    },
    {
      "base_volume": "0.0001",
      "price": "59216.7400",
      "target_volume": "2.9608",
      "trade_id": 293655136,
      "trade_timestamp": "1723870785",
      "type": "sell"
    }
  ]
}
```

***

## Errors

If error occurs, each endpoint will return one of the following general HTTP response errors. Depending on the error, there might be a message indicating the reason of the error<br>

<table><thead><tr><th width="140">Error Code</th><th width="239">Error Text</th><th>Note</th></tr></thead><tbody><tr><td>400</td><td>Bad Request</td><td></td></tr><tr><td>401</td><td>Unauthorized</td><td></td></tr><tr><td>403</td><td>Forbidden</td><td></td></tr><tr><td>404</td><td>Not Found</td><td></td></tr><tr><td>405</td><td>Method Not Allowed</td><td></td></tr><tr><td>415</td><td>Unsupported Media Type</td><td></td></tr><tr><td>429</td><td>Too Many Requests</td><td></td></tr><tr><td>500</td><td>Internal Server Error</td><td></td></tr><tr><td>503</td><td>Service Unavailable</td><td></td></tr><tr><td>504</td><td>Gateway Timeout</td><td></td></tr></tbody></table>

#### Error Response Example

```json
{
  "status_code": 500,
  "status_text": "Internal Server Error",
  "message": "Please contact the administrator for further assistance."
}
```
