Getting Started
API Access Key
Your API access key is your unique authentication token used to gain access to the Coinlayer API. You can find yours by logging in to your Coinlayer account dashboard.
In order to authenticate with the API, simply append the access_key parameter to the API's base URL and set it to your API access key value.
Base URL:
Append your API access key: Here is an example API call illustrating how to authenticate with the Coinlayer API:
Sign Up to Run API Request
API Response
In the example API request above, the Coinlayer API's live endpoint was used. Below you will see the standard API response in JSON format containing exchange rate data for all available cryptocurrencies.
The basic structure of the counlayer API's JSON response is similar across all API endpoints. Throughout the API Endpoints section you will learn more about the meaning of each response object.
Available Endpoints
In total, the Coinlayer API offers 6 endpoints, each with its own functionality. Find a quick summary below.
- Live Data: Query the API for the latest available exchange rate data.
- Historical Data: Look up crypto rates for a specific date.
- Conversion Endpoint: Convert amounts between cryptocurrencies and target currencies.
- Time-Frame Data: Query the API for crypto data in a specific period.
- Change Data: Retrieve data about rate fluctuation in a specific period.
- List Endpoint: Retrieve a list of all available cryptocurrencies and target currencies.
Connecting via HTTPS
All plans available for the Coinlayer API come with support for 256-bit SSL encryption. To connect to the API via HTTPS, simply use the https protocol instead of standard http.
JSONP Callbacks
The Coinlayer API supports JSONP Callbacks, enabling you to enter a function name and cause the API to return your requested API result wrapped inside that function. In order to specify a callback, pass a function name into the API's callback GET parameter.
Example Request: In our example request we are specifying the function name to be MY_FUNCTION
Sign Up to Run API Request
Example Response: Your API response will be wrapped inside your preferred callback function.
Error Codes
Whenever a requested resource is not available or an API call fails for another reason, a JSON error is returned. Errors always come with an error code and a description.
Example Error: The following error is returned if your monthly API request volume has been exceeded.
Other Errors:
| Code | Type | Info |
|---|---|---|
404 | 404_not_found | The requested resource does not exist. |
101 | invalid_access_key | No API Key was specified or an invalid API Key was specified. |
103 | invalid_api_function | The requested API endpoint does not exist. |
104 | usage_limit_reached | The maximum allowed API amount of monthly API requests has been reached. |
106 | no_rates_available | The current request did not return any results. |
102 | inactive_user | The account this API request is coming from is inactive. |
201 | invalid_target_currency | An invalid target currency has been entered. |
202 | invalid_currency_symbols | One or more invalid symbols have been specified. |
302 | invalid_date | An invalid date has been specified. [historical, convert] |
403 | invalid_conversion_amount | No or an invalid amount has been specified. [convert] |
501 | no_timeframe_supplied | No or an invalid timeframe has been specified. [timeframe] |
502 | invalid_start_date | No or an invalid "start_date" has been specified. [timeframe, change] |
503 | invalid_end_date | No or an invalid "end_date" has been specified. [timeframe, change] |
504 | invalid_time_frame | An invalid timeframe has been specified. [timeframe, change] |
505 | time_frame_too_long | The specified timeframe is too long, exceeding 365 days. [timeframe, change] |