Example
git clone --branch v1.1.0 https://git.datacoria.com/Phylex/as213905-sdk.git
cd as213905-sdk/javascript
npm installExample
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;
}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.