Crypto Price API

The Crypto Price API provides access to live market prices for several hundred different cryptocurrencies.

/v1/cryptoprice GET

https://api.api-ninjas.com/v1/cryptoprice

Returns the current price and current time (in UNIX timestamp in seconds) for any cryptocurrency symbol. For historical price data, see /v1/cryptopricehistorical.


Parameters

  • symbol  required

    Cryptocurrency symbol (e.g. LTCBTC). To get the full list of available symbols, use the Crypto Symbols API.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

symbol
https://api.api-ninjas.com/v1/cryptoprice?symbol=LTCBTC

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 { "symbol": "LTCBTC", "price": "0.00381400", "timestamp": 1637809196 }

Code Examples

1 2 3 4 5 6 7 8 import requests symbol = 'LTCBTC' api_url = 'https://api.api-ninjas.com/v1/cryptoprice?symbol={}'.format(symbol) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

/v1/cryptopricehistorical GET Premium Only

https://api.api-ninjas.com/v1/cryptopricehistorical

Returns historical price data for any cryptocurrency pair in OHLCV (Open, High, Low, Close, Volume) format. The data is returned in descending order (most recent first).


Parameters

  • symbol  required

    Cryptocurrency symbol (e.g. LTCBTC). Use the same values as the symbol parameter in /v1/cryptoprice.

  • interval  optional

    Time interval between data points. Valid values are: 1m, 5m, 15m, 30m, 1h, 4h, 1d. Default is 5m.

  • start  optional

    Start timestamp in Unix format (in seconds). If not provided, defaults to 24 hours ago.

  • end  optional

    End timestamp in Unix format (in seconds). If not provided, defaults to current time.

  • limit  optional

    Maximum number of data points to return. Default is 100, maximum is 1000.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Historical Price Sample Request

https://api.api-ninjas.com/v1/cryptopricehistorical?symbol=LTCBTC&interval=1h&start=1637809196&end=1637895596&limit=10

Historical Price Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 [ { "timestamp": 1637812799, "price": "0.00380900" }, { "timestamp": 1637816399, "price": "0.00381400" }, { "timestamp": 1637819999, "price": "0.00378100" }, { "timestamp": 1637823599, "price": "0.00377400" }, { "timestamp": 1637827199, "price": "0.00376700" }, { "timestamp": 1637830799, "price": "0.00373900" }, { "timestamp": 1637834399, "price": "0.00376200" }, { "timestamp": 1637837999, "price": "0.00382400" }, { "timestamp": 1637841599, "price": "0.00384200" }, { "timestamp": 1637845199, "price": "0.00391400" } ]