This project is designed to help you make your own projects that interact with the Blockcc API. providing complete API coverage, and supporting synchronous requests, as well as event streaming using WebSockets.
简体中文|English
npm install blockcc-api
import * as blockcc from 'typescript_api_test'
const client = new blockcc.HttpClient("YOUR_API_KEY");
console.log(await client.getTickers(
"gate-io",
"bitcoin"
));
console.log(await client.getPrices(
"bitcoin"
));
console.log(await client.getHistoryPrices(
"bitcoin",
1610596800000,
1611288000000,
blockcc.Interval.ONE_HOUR
));
console.log(await client.getOrderBook("gate-io_BTC_USDT", 10));
console.log(await client.getMarkets("gate-io"));
console.log(await client.getSymbols("bitcoin", false));
console.log(await client.getExchangeRate());
console.log(await client.getTrades("gate-io_BTC_USDT"));
console.log(await client.getKline("gate-io_BTC_USDT"));
console.log(await client.getBriefs(Locale.zh_CN));
console.log(await client.getAnnouncements(Locale.zh_CN, "binance"));
console.log(await client.getArticles(Locale.zh_CN));
console.log(await client.getArticle("5e1d96a5aeae8770b7ff34ac"));
console.log(await client.getSocialMedia(Source.WEIBO));
const client = new blockcc.WebSocketClient("YOUR_API_KEY");
After connecting to the WebSocket client, you need to reply to the subscription message. The format of the subscription message is as follows
{
"op": "subscribe",
"args": [
"price:bitcoin"
]
}
Our client provides a method to directly construct a subscription message, which can be used directly as parameters, as shown below
new Promise<void>(resolve => {
client.subscribe((data: any) => {
console.log(data);
resolve();
},
blockcc.price("bitcoin"),
blockcc.ticker("binance_BNB_USDT"),
blockcc.orderbook("binance_BTC_USDT"));
});