Runnable TypeScript examples that call the Bluebot Management API using a fully typed client generated with openapi-typescript and openapi-fetch.
Each script in src/examples/ corresponds 1:1 to an example documented in the Bluebot Developer Center.
git clone https://github.com/bluebot/bluebot-typescript-examples.git
cd bluebot-typescript-examples
npm install
cp .env.example .env
# fill in BLUEBOT_API_KEY (and BLUEBOT_DEVICE_ID for the flow examples)
npm run list-organizationsTypes are generated once from the management API's OpenAPI document and committed to src/schema.d.ts.
npm run openapi:generateThat runs:
openapi-typescript https://prod.bluebot.com/management/v1/api-json -o ./src/schema.d.tsRe-run it whenever the API spec changes — TypeScript will surface breaking changes at compile time.
src/client.ts creates a single typed client and registers a middleware that attaches the bluebot-api-key header to every outbound request. The key is read from BLUEBOT_API_KEY in the environment.
| Script | Endpoint | Notes |
|---|---|---|
npm run list-organizations |
GET /management/v1/organizations/mine |
The org the API key is scoped to. |
npm run list-devices |
GET /management/v1/device |
Page through devices. |
npm run historical-last-hour |
GET /management/v1/flow/datapoints/{id} |
5-minute buckets, last hour. |
npm run historical-raw-5min |
GET /management/v1/flow/datapoints/{id} |
Raw rows, last 5 minutes. |
npm run historical-daily-totals |
GET /management/v1/flow/datapoints/{id} |
Daily totals over the past 30 days. |
npm run historical-count-only |
GET /management/v1/flow/datapoints/{id} |
Just the row count. |
npm run adaptive-1day |
GET /management/v1/flow/adaptive/{id} |
~500 datapoints over 24 hours. |
npm run adaptive-7day |
GET /management/v1/flow/adaptive/{id} |
~1000 datapoints over 7 days. |
npm run adaptive-30day-tz |
GET /management/v1/flow/adaptive/{id} |
30 days, in your timezone. |
npm run latest-all-metrics |
GET /management/v1/flow/latest |
Uptime, last-seen, quality. |
npm run latest-lastseen-multi |
GET /management/v1/flow/latest |
Just last-seen across many devices. |
npm run latest-uptime-1h |
GET /management/v1/flow/latest |
Uptime over the past hour. |
| Var | Required by | Description |
|---|---|---|
BLUEBOT_API_KEY |
every script | Your management API key. |
BLUEBOT_API_BASE_URL |
every script | API root. Defaults to https://prod.bluebot.com. Set to https://prod.bluebot.com to hit prod. |
BLUEBOT_DEVICE_ID |
historical-*, adaptive-* |
A single device id (UUID, serial number, or NUID). |
BLUEBOT_DEVICE_IDS |
latest-* |
Comma-separated device ids. |