Official SDK
JavaScript SDKThe ESM client works in Node.js 18+ and modern runtimes with fetch. A custom fetch implementation and AbortSignal may be supplied.
Installation
Example
git clone --branch v1.1.0 https://git.datacoria.com/Phylex/as213905-sdk.git
cd as213905-sdk/javascript
npm install
Complete example
Example
import {AS213905, APIError} from './src/index.js';

const client = new AS213905({
  apiKey: process.env.AS213905_API_KEY,
});

try {
  const traffic = await client.traffic({days: 7});
  console.log(`p95: ${traffic.p95_kbps} kbps`);
} catch (error) {
  if (error instanceof APIError) {
    console.error(error.status, error.code, error.requiredScope);
  }
  throw error;
}
Production usage
Credential handling
Read the API key from a secret or environment variable. Reuse one client instance, set request cancellation in your application, and handle 429 responses according to Retry-After.