The alanphelan/cryptocurrency-daily-rates-usd v1.0.0 API is organized around multiple Web Services and protocols (REST, SOAP etc.). Allowing you to speed up the implementation by choosing the technology you are most familiar with and the one that best suits your needs.
You can use the alanphelan/cryptocurrency-daily-rates-usd API in test mode, which does not affect your request limits. The API key you use to authenticate the request determines whether it is live mode or test mode.
We put a lot of time and effor for the API's to be backward compatible but with new features available this may not be possible. If you wish we can notify you when the new version of the API is released.
https://assetsapi.com/alanphelan/cryptocurrency-daily-rates-usd/v1.0.0/rest
Choose the language you're going to use to implement the API. Examples will be adjusted accordingly.
The alanphelan/cryptocurrency-daily-rates-usd API uses API keys to authenticate requests. You can view and manage your API keys in the API Keys section.
Test mode secret keys have the prefix test_
and live mode secret keys have the prefix live_
.
Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
Open your application configuration file, where you hold all sensitive information. This is the file where environment setup is stored, such as database credentials, cache drivers, API keys etc.
Add constant defines below to the configuration file.
<?php // settings.php
// ...
defined("ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_SECRET") OR
define("ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_SECRET",
"test_YOUR_API_KEY_HASH");
defined("ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_ENDPOINT") OR
define("ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_ENDPOINT",
"https://assetsapi.com/alanphelan/cryptocurrency-daily-rates-usd/v1.0.0/rest");
Add the function below to your function helpers file. This makes the resources call examples more compact.
<?php // helpers.php
if (!function_exists("assetsAPI")) {
function assetsAPI($url, $secret, $params = [], $method = 'GET') {
$curl = curl_init($url . "?" . ($params ? http_build_query($params) : null ));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode($secret),
]);
// Execute cURL request
if (false === $response = curl_exec($curl)) {
$response = json_encode([
"success" => false,
"data" => null,
"error" => [
"code" => 1001,
"message" => curl_error($curl),
],
]);
}
// Closes a cURL session and frees all resources
curl_close($curl);
return json_decode($response);
}
}
The alanphelan/cryptocurrency-daily-rates-usd v1.0.0 API uses conventional HTTP response codes and response body to indicate the success or failure of an API request.
In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with our server.
{ "success": false,
"data": null,
"pagination": null,
"error": {
"code": 1001,
"message": "Could not resolve host"
}
}
# | Message | Description |
---|---|---|
200 | OK | Everything worked as expected. |
400 | Bad Request | The request was unacceptable, often due to missing a required parameter. |
401 | Unauthorized | No valid API key provided. |
402 | Request Failed | The parameters were valid but the request failed. |
403 | Forbidden | The API key doesn't have permissions to perform the request. |
404 | Not Found | The requested asset doesn't exist. |
409 | Conflict | The request conflicts with another request (perhaps due to using the same idempotent key). |
422 | Results Limit Reached | You have reached or will soon reach your results limit. |
429 | Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
500, 502, 503, 504 | Server Errors | Something went wrong on the server end. Those are logged and promptly fixed. |
1001 | Client Error | eg: Could not resolve host. |
$url = ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_ENDPOINT . "/WrongAsset";
$params = array (
);
$output = assetsAPI($url, ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_SECRET, $params);
{ "success": false,
"data": null,
"pagination": null,
"error": {
"code": 404,
"message": "The requested asset \"WrongAsset\" doesn't exist"
}
}
List of crypto rates for a specific day
Attributes |
Example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
integer | id | 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Unique ID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
string | currency_code | BTC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
crypto currency code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dateTime | date | 2021-12-01 00:00:00 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | volume_currency | 5181.22611006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
number of lots traded in a crypto currency | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | volume_usd | 296573382.53983440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
number of lots traded in a USD | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | low | 56505.00000000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lowest cryptocurrency rate for a specific day | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | high | 59055.00000000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
highest cryptocurrency rate for a specific day | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | open | 56988.82934176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
opening cryptocurrency rate for a specific day | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
decimal | close | 57240.00000000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
closing cryptocurrency rate for a specific day | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timestamp | created_at | 2022-03-28 12:53:09 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Record create time | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timestamp | updated_at | 2022-03-28 12:53:09 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Record update time |
$url = ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_ENDPOINT . "/crypto_currency_usd_rates";
$params = array (
);
$output = assetsAPI($url, ALANPHELAN_CRYPTOCURRENCY_DAILY_RATES_USD_SECRET, $params);
{ "success": true, pagination: {...},
"data": [
{
"id": 118,
"currency_code": "BTC",
"date": "2021-12-01 00:00:00",
"volume_currency": "5181.22611006",
"volume_usd": "296573382.53983440",
"low": "56505.00000000",
"high": "59055.00000000",
"open": "56988.82934176",
"close": "57240.00000000",
"created_at": "2022-03-28 12:53:09",
"updated_at": "2022-03-28 12:53:09"
}, ...
]
}