ℹ️SDK under development
The official TypeScript SDK is not yet available. In the meantime, you can call the API directly using fetch.
Direct API usage with fetch
Basic example
const BASE_URL = "https://kwery-api.com";
const API_KEY = "YOUR_KEY";
const res = await fetch(`${BASE_URL}/v1/binance/spot/BTCUSDT/ticker?api-key=${API_KEY}`);
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
}
const data = await res.json();
console.log(data);
Reusable client
const BASE_URL = "https://kwery-api.com";
const API_KEY = "YOUR_KEY";
async function kwery<T = unknown>(path: string): Promise<T> {
const res = await fetch(`${BASE_URL}${path}?api-key=${API_KEY}`);
if (!res.ok) {
const body = await res.text();
throw new Error(`HTTP ${res.status}: ${body}`);
}
return res.json() as Promise<T>;
}
const spot = await kwery("/v1/binance/spot/ETHUSDT/ticker");
const futures = await kwery("/v1/binance/futures/ETHUSDT/ticker");
const oracle = await kwery("/v1/chainlink/ETH-USD");
console.log({ spot, futures, oracle });
Error handling
try {
const res = await fetch(
"https://kwery-api.com/v1/binance/spot/INVALID/ticker?api-key=YOUR_KEY"
);
if (!res.ok) {
const error = await res.json();
console.error(`HTTP ${res.status}:`, error);
}
} catch (err) {
console.error("Network error:", err);
}
See also
- cURL Examples — complete endpoint reference with curl commands
- Authentication — API key setup and usage
- Error Codes — full error reference