π Crypto Price API is a lightweight suite of API provided by Bitquery to fetch and stream live cryptocurrency prices, historical data, and token analytics across multiple blockchains, using its Trading API Endpoints.
A Crypto Price API allows developers to access real-time and historical cryptocurrency prices programmatically. Bitqueryβs Crypto Price API provides data for tokens across chains like Ethereum, Solana, BSC, Polygon, and Tron β all through simple GraphQL queries or WebSocket streams.
- Get the latest token price in USD
- Stream live token price updates
- Get price change percentage for ROI calculations
- Get token volume data with configurable time intervals
- Stream live token volume updates
- Get volume data for multiple tokens simultaneously
- Stream live volume updates for multiple tokens simultaneously
- Convert token addresses into
currencyIdfor queries - Extendable query SDK workflow for adding new APIs
- Open source & developer-friendly
npm install bitquery-crypto-priceGet Your Bitquery Access Token here
const { getTokenPrice } = require("bitquery-crypto-price");
(async () => {
const data = await getTokenPrice("<Access Token>", "TOKEN ADDRESS");
console.log(data);
})();const { getTokenPriceStream } = require("bitquery-crypto-price");
const ws = getTokenPriceStream("<Access Token>", "TOKEN ADDRESS", {
autoCloseMs: 15000, // optional: auto-close after 15 seconds
onData: (data) => {
console.log("Live BTC Price:", JSON.stringify(data, null, 2));
},
onError: (err) => {
console.error("Stream error:", err);
},
});
// ws.close() // manually close if neededconst { getPriceChange } = require("bitquery-crypto-price");
(async () => {
const data = await getPriceChange("<Access Token>", "CURRENCY_ID");
console.log( JSON.stringify(data, null, 2));
})();const { getPriceChangeStream } = require("bitquery-crypto-price");
const ws = getPriceChangeStream("<Access Token>", "CURRENCY_ID", {
autoCloseMs: 30000, // optional: auto-close after 30 seconds
onData: (data) => {
console.log("Live price changes:", JSON.stringify(data, null, 2));
},
onError: (err) => {
console.error("Stream error:", err);
},
});
// ws.close() // manually close if neededconst { getTokenVolume } = require("bitquery-crypto-price");
(async () => {
const data = await getTokenVolume("<Access Token>", "TOKEN ADDRESS", 3600); // 3600 = 1 hour interval
console.log(JSON.stringify(data, null, 2));
})();const { getTokenVolumeStream } = require("bitquery-crypto-price");
const ws = getTokenVolumeStream("<Access Token>", "TOKEN ADDRESS", {
interval: 3600, // optional: time interval in seconds (default: 3600)
autoCloseMs: 30000, // optional: auto-close after 30 seconds
onData: (data) => {
console.log("Live token volume:", JSON.stringify(data, null, 2));
},
onError: (err) => {
console.error("Stream error:", err);
},
});
// ws.close() // manually close if neededconst { getMultipleTokenVolume } = require("bitquery-crypto-price");
(async () => {
const tokenAddresses = [
"0x4d15a3a2286d883af0aa1b3f21367843fac63e07", // WETH
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
"0xdac17f958d2ee523a2206206994597c13d831ec7" // USDT
];
const data = await getMultipleTokenVolume("<Access Token>", tokenAddresses, 3600); // 3600 = 1 hour interval
console.log(JSON.stringify(data, null, 2));
})();const { getMultipleTokenVolumeStream } = require("bitquery-crypto-price");
const tokenAddresses = [
"0x4d15a3a2286d883af0aa1b3f21367843fac63e07", // WETH
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
"0xdac17f958d2ee523a2206206994597c13d831ec7" // USDT
];
const ws = getMultipleTokenVolumeStream("<Access Token>", tokenAddresses, {
interval: 3600, // optional: time interval in seconds (default: 3600)
autoCloseMs: 30000, // optional: auto-close after 30 seconds
onData: (data) => {
console.log("Live multiple token volumes:", JSON.stringify(data, null, 2));
},
onError: (err) => {
console.error("Stream error:", err);
},
});
// ws.close() // manually close if needed| Function | Description |
|---|---|
getCurrencyId |
Get currencyId from a token address (required for queries) |
getTokenPrice |
Fetch the latest token price (point-in-time query) |
getTokenPriceStream |
Subscribe to real-time token price updates (WebSocket stream) |
getPriceChange |
Get top tokens by price change percentage (point-in-time query) |
getPriceChangeStream |
Subscribe to real-time price change updates (WebSocket stream) |
getTokenVolume |
Fetch token volume data (point-in-time query) |
getTokenVolumeStream |
Subscribe to real-time token volume updates (WebSocket stream) |
getMultipleTokenVolume |
Fetch volume data for multiple tokens (point-in-time query) |
getMultipleTokenVolumeStream |
Subscribe to real-time volume updates for multiple tokens (WebSocket stream) |
When using the stream functions (*Stream functions), you are charged based on simultaneous active streams. We don't count based on number of tokens monitored.
- Billing Model: Each active stream subscription is charged
- Separate Subscriptions: Each stream function call counts as a separate subscription:
getTokenPriceStream()= 1 subscriptiongetMultipleTokenVolume()= 1 subscriptiongetTokenVolumeStream()= 1 subscription- Running multiple streams simultaneously = multiple subscriptions
Important Notes:
- Billing is based on number of subscriptions and duration, not query complexity or data volume
- Check your points usage and manage subscriptions at your Bitquery Account Dashboard
For detailed pricing information, contact sales by filling the form on the Bitquery website
To add support for more Trading APIs (e.g., OHLC candles, trades, liquidity pools):
-
Create a new query file in
queries/with naming convention:<result-returned>-query.jsExample:sample-query.jsconst sampleQuery = (currencyId) => { return ` <Your GraphQL Query> `; }; const sampleStream = (currencyId) => { return ` <Your GraphQL Subscription> `; }; module.exports = { sampleQuery, sampleStream };
-
Import into
index.js:const { sampleQuery, sampleStream } = require("./queries/sample-query.js");
-
Wrap with a function for queries or streams in
index.js:const getSample = async (token, tokenId) => { const query = sampleQuery(tokenId); const data = await queryRunner(query, token); return data; }; const getSample = (token, tokenId, options = {}) => { const subscription = sampleStream(tokenId); return streamRunner(subscription, token, options); };
Thatβs it! Your new query is available to all SDK users after PR merge and release.
- Fork this repo https://github.com/bitquery/crypto-price-api
- Create a feature branch
- Follow the workflow for adding queries
- Submit a PR π
- Make sure to follow the Contribution Guidelines
MIT License. Free to use and modify.
Contact our team via Telegram for any support. Fill out this form, if you are interested in purchasing any product or service from Bitquery.