Get coin price
The price endpoint allows users to query the price history of a cryptocurrency based on a specified epoch timestamp (in seconds). The system will find the nearest available price point to the provided timestamp, selecting from data aggregated by minute, hour, or day. The granularity of the returned data depends on how far back in time the requested timestamp is.
https://api.coinranking.com/v2/coin/:uuid/price
Path parameters
| Parameter | Description |
|---|---|
uuid String | UUID of the coin you need the price. |
Query parameters
| Parameter | Description |
|---|---|
referenceCurrencyUuid (optional) String | UUID of coin (either fiat or crypto), in which all the prices are calculated. 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: yhjMzLPhuIDlExample:
https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?referenceCurrencyUuid=5k-_VTxqtCEI
|
timestamp (optional) Number | The timestamp parameter accepts an epoch timestamp in seconds. This timestamp is used to find the nearest available price point, selecting the data's granularity based on the age of the request:
If no timestamp is provided, this endpoint will default to the latest price. Example:
https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?timestamp=1588349307
|
Code examples
curl 'https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?referenceCurrencyUuid=5k-_VTxqtCEI' \
-H 'x-access-token: your-api-key' \
-G const options = {
headers: {
'x-access-token': 'your-api-key',
},
};
fetch('https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?referenceCurrencyUuid=5k-_VTxqtCEI', options)
.then((response) => response.json())
.then((result) => console.log(result)); <?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?referenceCurrencyUuid=5k-_VTxqtCEI",
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; import requests
headers = {
'x-access-token': 'your-api-key'
}
response = requests.request("GET", "https://api.coinranking.com/v2/coin/Qwsogvtv82FCd/price?referenceCurrencyUuid=5k-_VTxqtCEI", headers=headers)
print(response.text) Response
HTTP/1.1 200 OK
{
"status": "success",
"data": {
"price": "7305.985182338483",
"timestamp": 1586305740
}
} Response fields
| Property | Description |
|---|---|
status String | Status of the request Allowed values:success |
data Object | |
data.price String | The price of the requested coin at the requested time |
data.timestamp Number | An Epoch timestamp in seconds when the coin had the given price. Might differ from the provided timestamp in the request, because it is stripped down to the day, hour or minute. |
Error response
HTTP/1.1 404 Not Found
{
"status": "fail",
"type": "COIN_NOT_FOUND",
"message": "Coin not found"
} Error responses
| Error | Description |
|---|---|
PRICE_NOT_FOUND Object | No price could be calculated for this request. Try another coin and/or another reference currency |
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. |