The Bitcoin API provides access to the latest Bitcoin price and market data.
https://api.api-ninjas.com/v1/bitcoin
Returns the latest Bitcoin price in USD and 24-hour market data. For historical price data, see /v1/bitcoinhistorical.
X-Api-Key
requiredAPI Key associated with your account.
price
The price of Bitcoin in USD.
timestamp
The timestamp of the price in Unix format (in seconds).
24h_price_change
The price change of Bitcoin in USD over the last 24 hours.
24h_price_change_percent
The price change percentage of Bitcoin over the last 24 hours.
24h_high
The highest price of Bitcoin in USD over the last 24 hours.
24h_low
The lowest price of Bitcoin in USD over the last 24 hours.
24h_volume
The volume of Bitcoin traded over the last 24 hours.
https://api.api-ninjas.com/v1/bitcoin
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
5
6
7
8
9
{
"price": "94962.21000000",
"timestamp": 1736824504,
"24h_price_change": "849.92000000",
"24h_price_change_percent": "0.903",
"24h_high": "95222.00000000",
"24h_low": "89438.45000000",
"24h_volume": "26.39660000"
}
1
2
3
4
5
6
7
import requests
api_url = 'https://api.api-ninjas.com/v1/bitcoin'
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.
https://api.api-ninjas.com/v1/bitcoinhistorical
Returns historical price data for Bitcoin in USD.
interval
optionalTime interval between data points. Valid values are: 1m
, 5m
, 15m
, 30m
, 1h
, 4h
, 1d
. Default is 5m
.
start
optionalStart timestamp in Unix format (in seconds). If not provided, defaults to 24 hours ago.
end
optionalEnd timestamp in Unix format (in seconds). If not provided, defaults to current time.
limit
optionalMaximum number of data points to return. Default is 100, maximum is 1000.
X-Api-Key
requiredAPI Key associated with your account.
price
The price of Bitcoin in USD.
timestamp
The timestamp of the price in Unix format (in seconds).
https://api.api-ninjas.com/v1/bitcoinhistorical?interval=1h&start=1637809196&end=1637895596&limit=10
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": "57713.69000000"
},
{
"timestamp": 1637816399,
"price": "57258.49000000"
},
{
"timestamp": 1637819999,
"price": "57120.91000000"
},
{
"timestamp": 1637823599,
"price": "57253.15000000"
},
{
"timestamp": 1637827199,
"price": "57652.55000000"
},
{
"timestamp": 1637830799,
"price": "57563.02000000"
},
{
"timestamp": 1637834399,
"price": "57773.22000000"
},
{
"timestamp": 1637837999,
"price": "57997.06000000"
},
{
"timestamp": 1637841599,
"price": "57990.62000000"
},
{
"timestamp": 1637845199,
"price": "58646.55000000"
}
]