Kraken TypeScript SDK example: marketData.ts
Kraken Spot Public market data example for the Siebly Kraken SDK, with TypeScript source for exchange REST API and WebSocket integration, setup, and production SDK docs.
What This Example Covers
- Kraken exchange API example in TypeScript.
- Uses the Siebly Kraken SDK package
@siebly/kraken-apiinstead of hand-written HTTP request plumbing. - Source path:
Kraken/Spot/Public/marketData.ts. - Example category: Spot Public.
- Imports SDK symbols including
SpotClient. - Calls SDK methods such as
getServerTime(),getSystemStatus(),getAssetInfo(),getAssetPairs(),getTicker(),getOrderBook(),getCandles(),getRecentTrades(),getRecentSpreads().
How To Use This Example
- Start here for the specific request or stream pattern, then check the matching SDK guide for install, credentials, and operational notes.
- Open the repository source when you need the latest committed version: GitHub source file.
Example Path
Kraken/Spot/Public/marketData.ts
Source Link
Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Kraken/Spot/Public/marketData.ts
Related SDK Docs
Example Source
import { SpotClient } from '@siebly/kraken-api';
// This example shows how to call Kraken API endpoint with either node.js,
// javascript (js) or typescript (ts) with the npm module "@siebly/kraken-api" for Kraken exchange
// for PUBLIC MARKET DATA that requires no authentication
// you can initialise public client without api keys as public calls do not require auth
const client = new SpotClient();
async function publicCalls() {
try {
// Get server time
const serverTime = await client.getServerTime();
console.log('Server Time: ', serverTime);
// Get system status
const systemStatus = await client.getSystemStatus();
console.log('System Status: ', systemStatus);
// Get asset info
const assetInfo = await client.getAssetInfo({
asset: 'XBT,ETH',
});
console.log('Asset Info: ', assetInfo);
// Get tradable asset pairs
const assetPairs = await client.getAssetPairs({
pair: 'XBTUSD,ETHUSD',
});
console.log('Asset Pairs: ', assetPairs);
// Get ticker information
const ticker = await client.getTicker({
pair: 'XBTUSD',
});
console.log('Ticker: ', ticker);
// Get order book
const orderBook = await client.getOrderBook({
pair: 'XBTUSD',
count: 10,
});
console.log('Order Book: ', orderBook);
// Get OHLC data (candles)
const candles = await client.getCandles({
pair: 'XBTUSD',
interval: 60, // 1 minute
});
console.log('OHLC Candles: ', candles);
// Get recent trades
const recentTrades = await client.getRecentTrades({
pair: 'XBTUSD',
count: 10,
});
console.log('Recent Trades: ', recentTrades);
// Get recent spreads
const recentSpreads = await client.getRecentSpreads({
pair: 'XBTUSD',
});
console.log('Recent Spreads: ', recentSpreads);
} catch (e) {
console.error('Error: ', e);
}
}
publicCalls();