Crypto Price API: How to Get Bitcoin and Altcoin Prices in Any Currency
6 min read
If you need the price of Bitcoin in euros, or Ethereum in Japanese yen, a crypto price API gives you that as one HTTP request. You send a base asset and a quote currency. You get back a rate, a timestamp and some indication of how fresh it is. The hard parts are not the request itself. They are knowing what a quoted pair really means, handling prices that have many decimals, and polling often enough without wasting your quota.
This guide covers how crypto prices are quoted, why "any pair" support depends on derived rates, and how to read freshness fields before you show a number to a user. It ends with a working example and a way to estimate how many requests a price feed needs.
How crypto prices are quoted
Exchanges list crypto against a small set of quote assets, usually USD, USDT, EUR and BTC. A market called BTC/USD says how many US dollars one bitcoin costs. There is no market for most combinations. Nobody lists a direct BTC/CZK or a direct small-cap token against Thai baht.
An API that only returns direct markets would fail on many of the pairs your users want. A better one fills the gap by chaining rates through a common asset. If you want ETH in CZK, it can take ETH/USD and multiply by USD/CZK. The math is the same one used for cross rates between fiat currencies.
Two details matter when you use derived prices:
- The timestamp is only as new as the oldest input. If ETH/USD was observed 5 seconds ago and USD/CZK 50 seconds ago, the combined price is 50 seconds old.
- You should know which kind you got. A direct quote and a derived quote have different failure modes, so a good API labels them.
What a good crypto rate response contains
A price alone is not enough to build on. Look for these fields in whatever API you choose:
| Field | Why you need it |
|---|---|
| Rate as a string | Avoids float rounding and keeps every digit |
| Observation time | Lets you show "updated 8 seconds ago" and detect lag |
| Freshness status | Tells you whether to trust, warn or retry |
| Direct or derived type | Explains the age and source of the number |
GetRatesAPI returns all four on every rate. Here is an example response for a fiat pair (the numbers are illustrative):
{"base":"EUR","quote":"USD","rate":"1.0842","as_of":"2026-01-02T10:00:00Z","status":"fresh","type":"direct"}
Crypto responses use the same shape. Crypto prices refresh every 10 seconds, and a crypto rate is flagged "stale" after 1 minute without an update. Fiat currencies and metals refresh every 60 seconds and are flagged stale after 5 minutes. Stale rates are still returned, with the flag set, so your code decides what to do with them.
The API covers thousands of crypto assets plus about 170 fiat currencies and metals, and the full list is on the currencies page. Any pair works, because missing pairs are derived through USD, EUR or BTC.
Fetching a Bitcoin price in any fiat currency
Authentication is a single header, Authorization: ApiKey <key>. Keys are created in the dashboard. See the authentication docs for rotation and revocation.
One rate with curl:
curl -H "Authorization: ApiKey $GETRATES_API_KEY" \
"https://api.getratesapi.com/v1/rates/BTC/EUR"
Several quote currencies against one base in a single call (up to 20 quotes, still one request unit):
curl -H "Authorization: ApiKey $GETRATES_API_KEY" \
"https://api.getratesapi.com/v1/rates/BTC?quote=USD,EUR,GBP,JPY"
Codes the API does not support are listed under unsupported instead of failing the whole call. That is handy when the quote list comes from user settings. The current rate reference documents both forms.
A Python example with exact decimals
Parse rates as Decimal, never as float. A float cannot represent most decimal fractions exactly, and crypto amounts often have many places.
import os
from decimal import Decimal
import requests
API = "https://api.getratesapi.com"
HEADERS = {"Authorization": f"ApiKey {os.environ['GETRATES_API_KEY']}"}
def get_price(base: str, quote: str) -> dict:
resp = requests.get(f"{API}/v1/rates/{base}/{quote}", headers=HEADERS, timeout=5)
if not resp.ok:
# Match on the error code, not on the message text.
raise RuntimeError(resp.json().get("code", "unknown_error"))
data = resp.json()
data["rate"] = Decimal(data["rate"])
return data
price = get_price("BTC", "EUR")
if price["status"] == "stale":
print("Warning: price is stale, last observed", price["as_of"])
print(price["rate"], price["type"])
To turn an amount of crypto into fiat, you can use the convert endpoint, which returns an exact converted_amount string:
curl -H "Authorization: ApiKey $GETRATES_API_KEY" \
"https://api.getratesapi.com/v1/convert?from=ETH&to=USD&amount=0.75"
The result is not rounded. Round only when you display or invoice, using the rules in our article on currency conversion rounding. For display, crypto prices usually need more decimals than fiat. For a ledger entry, use the precision your accounting policy specifies.
Decide what to do with stale prices
A stale flag means the latest observation is older than the freshness window. It does not mean the number is wrong, only that it may have moved. Choose a policy per use case:
- Price ticker on a dashboard: show the value with an "updated at" time and dim it when stale.
- Portfolio total: include the value but mark the total as approximate.
- Quote shown at checkout: refuse to lock a price on a stale rate. Retry once, then show a message.
- Background reporting: store the rate together with
as_ofandstatusso the report can be audited later.
Crypto moves quickly, so a 60-second-old price can differ materially from the market. Do not hide as_of from users who make decisions based on the number, and do not treat a displayed rate as a guaranteed execution price. Rates are data. They are not trading advice, and GetRatesAPI does not execute trades or payments.
Polling without burning your quota
GetRatesAPI is a request/response REST API. It does not offer WebSockets or streaming, so a live-looking feed means polling. Since crypto data updates every 10 seconds, polling faster than that gains you nothing.
Work out the budget before you pick an interval:
- One pair polled every 10 seconds is 6 requests a minute, or about 259,200 a month.
- One base against 20 quotes polled at the same interval costs the same, because a multi-quote call is 1 request unit.
- Ten separate single-pair calls every 10 seconds cost ten times as much.
That gap is the main lever. Group by base asset and use the multi-quote endpoint. Share one poller across all your users, rather than polling per browser tab, and serve the cached value to clients from your own backend. The caching rules, including how to expire entries by as_of instead of just by time, are in How to Cache Exchange Rates Without Showing Stale Prices.
Also plan for limits. Each plan has a monthly quota and a per-second rate limit. If you exceed the per-second limit you get rate_limit_exceeded (HTTP 429) with retry_after_seconds, and those requests are not billed. Back off for that long. The details are in handling 429 errors and retries. You can check consumption at any time through GET /v1/account/usage, which returns period, used, quota and remaining.
Common errors for crypto lookups
invalid_asset_symbol(400): the code is malformed. Validate input before calling.unsupported_pair(404): the asset is not in the catalog. Check againstGET /v1/assets/crypto, which is free.temporarily_unavailable(503): retry with a short backoff and serve your last known value flagged as old.
Malformed requests are not billed, so validating early is cheap but still worth doing. See the error reference for the full list.
Using crypto prices from an AI assistant
If an AI assistant needs a price, you do not have to write HTTP glue. GetRatesAPI also runs an MCP server with the tools get_rate, convert_currency, list_fiat_currencies, list_crypto_assets and get_usage. Claude, Cursor and other MCP clients can call them directly. The MCP setup guide shows the configuration.
Try it on the free plan
You can test every endpoint in the dashboard playground before you write code. The free plan needs no credit card. Create an account, copy a key, and run the BTC example above. When your polling budget grows, compare the options on the pricing page.