Get coin price history

Coinranking keeps track of prices on all listed assets. The history endpoint lists prices and their timestamp for the requested time period, useful for making a chart.

On Coinranking, we use this endpoint for the main price chart on our coin detail page.

https://api.coinranking.com/v2/coin/:uuid/price-history

Path parameters

Parameter Description
uuid String UUID of the coin you want to request

Query parameters

Parameter Description
timePeriod (optional) String

Timeperiod where the change and history are based on

The maximum timePeriod is 1y for Free, 5y for Basic, and all for Startup and higher plans. These historical windows apply to both preview and production requests.

Default value: 24h
Allowed values:
1h 3h 12h 24h 7d 30d 3m 1y 3y 5y all

Example:
https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?timePeriod=1y
referenceCurrencyUuid (optional) String

UUID of coin (either fiat or crypto), the price of the reference currency is used to calculate the volume. Defaults to US Dollar, but you can use any coin. You can find UUIDs for reference currencies in any coin endpoint, including a convenient dedicated reference currency endpoint

Default value: yhjMzLPhuIDl

Example:
https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?referenceCurrencyUuid=5k-_VTxqtCEI

Code examples

curl
curl 'https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?referenceCurrencyUuid=5k-_VTxqtCEI&timePeriod=7d' \
  -H 'x-access-token: your-api-key' \
  -G
JavaScript
const options = {
  headers: {
    'x-access-token': 'your-api-key',
  },
};

fetch('https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?referenceCurrencyUuid=5k-_VTxqtCEI&timePeriod=7d', options)
  .then((response) => response.json())
  .then((result) => console.log(result));
PHP
<?php
  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?referenceCurrencyUuid=5k-_VTxqtCEI&timePeriod=7d",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "x-access-token: your-api-key"
      ),
  ));

  $response = curl_exec($curl);

  curl_close($curl);
  echo $response;
Python
import requests

headers = {
  'x-access-token': 'your-api-key'
}

response = requests.request("GET", "https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price-history?referenceCurrencyUuid=5k-_VTxqtCEI&timePeriod=7d", headers=headers)

print(response.text)

Response

json
HTTP/1.1 200 OK
{
  "status": "success",
  "data": {
    "change": "12",
    "history": [
      {
        "price": "41905.99687434882803047615",
        "timestamp": 1641897900
      },
      {
        "price": "41937.93174219252237197408",
        "timestamp": 1641897600
      }
    ]
  }
}

Response fields

Property Description
status String

Status of the request

Allowed values:
success
data Object
data.change String

Percentage of change over the given time frame

data.history Object[]

List of prices

data.history.price String

Price of the coin

data.history.timestamp Number

An Epoch timestamp in seconds when the coin had the given price.

Error response

json
HTTP/1.1 404 Not Found
{
  "status": "fail",
  "type": "COIN_NOT_FOUND",
  "message": "Coin not found"
}

Error responses

Error Description
COIN_NOT_FOUND Object The coin could not be found. Try another UUID
Error Description
VALIDATION_ERROR Object

The request could not be validated. The response should provide more details.

REFERENCE_UNAVAILABLE Object

The reference currency used in the request is not available. Choose another UUID.