SDK
The official JavaScript and TypeScript client for the Outerview API. Discover places from a question, follow dataset changes with Stream, and verify webhooks. No dependencies.
- Package
- @outerview/sdk
- Version
- 0.2.0
- Runtimes
- Node 18+, Cloudflare Workers, Deno, Bun
- Types
- Included
Install
npm install @outerview/sdk
Authenticate
Create a key in the console and expose it to your server as OUTERVIEW_API_KEY. The client reads it automatically, or you can pass it in.
import { Outerview } from "@outerview/sdk";
const ov = new Outerview(); // reads OUTERVIEW_API_KEY
const ov2 = new Outerview({ apiKey: process.env.MY_KEY }); // or pass it explicitlyQuickstart
import { Outerview } from "@outerview/sdk";
const ov = new Outerview();
const { data, embed_url } = await ov.discover("public parks in Brooklyn", { limit: 5, answer: true });
console.log(data.answer);
for (const feature of data.geojson.features) {
const [lng, lat] = feature.geometry.coordinates;
console.log(feature.properties.name, lat, lng);
}
console.log("See them on the map:", embed_url);Discover
discover(query, options) finds places, objects, conditions and events from a question in plain words. Results come back as a GeoJSON FeatureCollection with an embed_url that opens them on outerview.ai. Each successful call uses one credit; failed calls are refunded.
| Option | Type | Description |
|---|---|---|
limit | number | 1–200 results. Default 20. |
answer | boolean | Add a short written answer in data.answer. Default false. |
focus | string | Numeric region id to search in when the query names no place. |
areas | [lng, lat][] | Up to four points to search around. |
where | object | Geographic attribute conditions, such as elevation or land cover. |
{
"isSuccess": true,
"id": "eabf9ebb-81ff-41cb-805c-a8a86154af51",
"embed_url": "https://outerview.ai/discover/eabf9ebb-81ff-41cb-805c-a8a86154af51",
"data": {
"query": "public parks in Brooklyn",
"answer": "Brooklyn has…",
"geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-73.969,
40.662
]
},
"properties": {
"name": "Prospect Park",
"feature_name": "Park"
}
}
]
},
"region": {
"id": "…",
"name": "Brooklyn"
},
"duration_ms": 812
}
}Read a stored result again for free with ov.result(id).
Find datasets
Datasets (artifacts) are what Discover searches and what Stream follows. Search them by name; only entries with streamable: true work with Stream.
const { data } = await ov.artifacts("building permit", { limit: 5 });
// [{ id: "3f1c…", name: "Building Permit", type: "event", scenes: 1203345, streamable: true }, …]Stream changes
Stream returns new and changed records in a dataset, oldest first, for the last seven days. Poll with a cursor, iterate, or push changes to a webhook. Stream is free.
// Follows the cursor for you. With follow: true it keeps polling every 15 seconds.
for await (const event of ov.stream.iterate({ artifact_id, since: "2026-12-01T00:00:00Z", follow: true })) {
console.log(event.operation, event.recorded_at, event.feature?.properties);
await save(event.cursor); // resume later from here
}Verify webhooks
Every delivery carries X-Outerview-Signature: t=TIMESTAMP,v1=HEX and X-Outerview-Event-ID. Verify against the raw body, deduplicate by event id, and return a 2xx.
import express from "express";
import { verifyWebhook } from "@outerview/sdk";
app.post("/webhooks/outerview", express.text({ type: "*/*" }), async (req, res) => {
const ok = await verifyWebhook({
body: req.body,
signature: req.get("x-outerview-signature"),
secret: process.env.OUTERVIEW_WEBHOOK_SECRET,
});
if (!ok) return res.sendStatus(400);
const { data } = JSON.parse(req.body); // { events, cursor, artifact, region }
res.sendStatus(200);
});Usage and credits
const { balance, spent, live } = await ov.usage();Errors
Non-2xx responses throw OuterviewError with status and the parsed body.
import { OuterviewError } from "@outerview/sdk";
try {
await ov.discover("bridges in Pittsburgh");
} catch (error) {
if (error instanceof OuterviewError && error.status === 402) {
// Out of credits: top up at https://outerview.ai/platform/dashboard/billing
} else if (error instanceof OuterviewError && error.status === 429) {
// Rate limited: wait and retry
} else throw error;
}| Status | Meaning |
|---|---|
| 400 | Invalid input, or a cursor that belongs to another dataset or region |
| 401 | Missing, invalid or revoked key |
| 402 | Workspace is out of credits |
| 404 | Result or subscription not found in this workspace |
| 429 | More than 60 requests a minute |
| 502 / 503 | Temporary failure; retry with backoff |
Full list: Errors and rate limits.
Configuration
| Option | Default | Description |
|---|---|---|
apiKey | OUTERVIEW_API_KEY | Your ov_ key. |
baseUrl | https://api.outerview.ai | Override for testing (or OUTERVIEW_BASE_URL). |
fetch | globalThis.fetch | Custom fetch, e.g. with a proxy or retries. |
client | sdk/0.2.0 | Sent as x-outerview-client. |
Reference
| Method | Returns | Cost |
|---|---|---|
discover(query, options?) | DiscoverResult | 1 credit |
result(id) | DiscoverResult | Free |
artifacts(q?, { type, limit }) | { data: Artifact[] } | Free |
usage() | { balance, spent, live, … } | Free |
stream.poll(options) | StreamBatch | Free |
stream.iterate(options) | AsyncGenerator<StreamEvent> | Free |
stream.subscribe(options) | StreamSubscription | Free |
stream.list / get / pause / resume / delete | StreamSubscription | Free |
verifyWebhook(input) | Promise<boolean> | — |