JavaScript SDK

One client for the BatchPipe /v1 HTTP API. The module is served from this deployment at https://www.batchpipe.com/sdk/batchpipe-sdk.mjs—no npm package required for browsers or runtimes that can load an ES module over HTTPS.

← Back to Docs

Hosted module URL

Stable path (same origin as the API you call with fetch):

Stable URL on this site (same origin you use for fetch and the dashboard):

https://www.batchpipe.com/sdk/batchpipe-sdk.mjs

Operators: set SOURCE_REPO_URL in the environment to show a link to the source repository on this page.

Browser (ES module)

<script type="module">
import { create_batchpipe_client } from 'https://www.batchpipe.com/sdk/batchpipe-sdk.mjs';

const client = create_batchpipe_client({
  base_url: 'https://www.batchpipe.com',
  api_key: 'bp_v1_…'
});

const health = await client.health();
console.log(health.data);

await client.ingest('PIPE_UUID', { event: 'page_view' });
</script>

Cross-origin import is allowed: the server sends Access-Control-Allow-Origin: * for /sdk/*.mjs.

Node.js (optional workspace package)

If you run from the product’s own source tree, you can depend on the workspace package batchpipe-sdk (import; the package is ESM). Otherwise use the hosted .mjs URL above when your runtime supports it.

import { create_batchpipe_client } from 'batchpipe-sdk';

const client = create_batchpipe_client({
  base_url: process.env.BATCHPIPE_BASE_URL || 'https://www.batchpipe.com',
  api_key: process.env.BATCHPIPE_API_KEY
});

Requirements

Global fetch (modern browsers, Node 18+, Deno, Bun). Use base_url pointing at the BatchPipe deployment that issued your API key.

Methods

Every async method returns { status, ok, data } with parsed JSON in data (or null for empty bodies). Method names use snake_case and mirror the HTTP management API where applicable.

SDK API reference — parameter and return types generated from JSDoc with documentation.js (npm run docs:sdk in the source tree).

Tests

Operators run npm run test:sdk from the deployment’s source tree with this server running. Set SOURCE_REPO_URL to link the repository here.

npm run test:sdk

HTTP reference

Status codes, auth, and payloads are documented on the HTTP API page.