TypeScript/JavaScript API Client
@owox/api-client is a TypeScript/JavaScript package for calling the OWOX Data Marts API from custom scripts, internal tools, automation, and local agent workflows.
Use owox-ctl for terminal commands. Use @owox/api-client for code-level integrations.
Install
Section titled âInstallânpm install @owox/api-clientCreate an API key
Section titled âCreate an API keyâBefore using @owox/api-client, create an API key. See API Keys.
Basic usage
Section titled âBasic usageâSet credentials as environment variables:
export OWOX_API_ORIGIN=https://app.owox.comexport OWOX_API_KEY_ID=pmk_xxxexport OWOX_API_KEY_SECRET=your_api_key_secretThen create a client:
import { OWOXApiClient } from '@owox/api-client';
const client = new OWOXApiClient({ apiOrigin: process.env.OWOX_API_ORIGIN!, apiKeyId: process.env.OWOX_API_KEY_ID!, apiKeySecret: process.env.OWOX_API_KEY_SECRET!,});
const dataMarts = await client.dataMarts.list();
console.log(dataMarts);List data marts
Section titled âList data martsâconst dataMarts = await client.dataMarts.list();List storages
Section titled âList storagesâconst storages = await client.storages.list();List destinations
Section titled âList destinationsâconst destinations = await client.destinations.list();Use in local agents and scripts
Section titled âUse in local agents and scriptsâLocal agents can run scripts that use @owox/api-client when they need structured access to OWOX Data Marts from TypeScript or JavaScript.
import { OWOXApiClient } from '@owox/api-client';
const client = new OWOXApiClient({ apiOrigin: process.env.OWOX_API_ORIGIN!, apiKeyId: process.env.OWOX_API_KEY_ID!, apiKeySecret: process.env.OWOX_API_KEY_SECRET!,});
const [dataMarts, storages, destinations] = await Promise.all([ client.dataMarts.list(), client.storages.list(), client.destinations.list(),]);
console.log( JSON.stringify( { dataMarts, storages, destinations, }, null, 2 ));Security notes:
- Do not hard-code API key secrets in source code.
- Use environment variables or a secret manager.
- Do not commit
.envfiles containing API key secrets. - Avoid putting API key secrets in agent instructions or prompts.
- Revoke keys that are no longer used.
Authentication behavior
Section titled âAuthentication behaviorâ@owox/api-client uses the API key ID and API key secret to request a short-lived access token.
The access token is kept in memory for the current process and is not persisted.
Error handling
Section titled âError handlingâ@owox/api-client exports typed errors for request and authentication failures.
import { OWOXApiError, OWOXAuthError } from '@owox/api-client';
try { const dataMarts = await client.dataMarts.list(); console.log(dataMarts);} catch (error) { if (error instanceof OWOXAuthError) { console.error('Authentication failed'); } else if (error instanceof OWOXApiError) { console.error(`OWOX API request failed: ${error.message}`); } else { throw error; }}Compatibility
Section titled âCompatibilityâThe same @owox/api-client and OWOX Data Marts server version is supported. Different versions are best effort.