The official TypeScript/JavaScript SDK for apitree. One import, 1,950+ APIs.
npm install @apitree/sdk
import { ApitreeClient } from '@apitree/sdk';
const apitree = new ApitreeClient('nxs_live_YOUR_KEY');
// Call any API
const result = await apitree.call('exchange-rates');
console.log(result.data);
console.log(result.meta.latency_ms);// Call up to 10 APIs concurrently
const batch = await apitree.batch([
{ api: 'exchange-rates' },
{ api: 'restcountries', path: 'all' },
{ api: 'open-meteo-weather', params: { latitude: 37.5, longitude: 127 } },
]);
batch.results.forEach(r => console.log(r));// Search APIs
const apis = await apitree.search('weather data');
// Get API details
const details = await apitree.getApi('exchange-rates');
// Check usage
const usage = await apitree.getUsage();
// Export usage logs
const csv = await apitree.exportUsage({ format: 'csv', days: 7 });
// Get credit balance
const credits = await apitree.getCredits();import { ApitreeClient, ApitreeError } from '@apitree/sdk';
try {
const result = await apitree.call('some-api');
} catch (err) {
if (err instanceof ApitreeError) {
console.log(err.status); // 429, 402, 502, etc
console.log(err.message);
}
}