Outerview

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.

Version
0.2.0
Runtimes
Node 18+, Cloudflare Workers, Deno, Bun
Types
Included

Install

bash
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.

ts
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 explicitly
Keep keys on the server. Never ship an API key in browser or mobile code; call Outerview from your backend and return only what the client needs.

Quickstart

ts
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.

OptionTypeDescription
limitnumber1–200 results. Default 20.
answerbooleanAdd a short written answer in data.answer. Default false.
focusstringNumeric region id to search in when the query names no place.
areas[lng, lat][]Up to four points to search around.
whereobjectGeographic attribute conditions, such as elevation or land cover.
JSON
{
  "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.

ts
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.

ts
// 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.

ts
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

ts
const { balance, spent, live } = await ov.usage();

See daily charts and every request in the console under Usage and Requests.

Errors

Non-2xx responses throw OuterviewError with status and the parsed body.

ts
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;
}
StatusMeaning
400Invalid input, or a cursor that belongs to another dataset or region
401Missing, invalid or revoked key
402Workspace is out of credits
404Result or subscription not found in this workspace
429More than 60 requests a minute
502 / 503Temporary failure; retry with backoff

Configuration

OptionDefaultDescription
apiKeyOUTERVIEW_API_KEYYour ov_ key.
baseUrlhttps://api.outerview.aiOverride for testing (or OUTERVIEW_BASE_URL).
fetchglobalThis.fetchCustom fetch, e.g. with a proxy or retries.
clientsdk/0.2.0Sent as x-outerview-client.

Reference

MethodReturnsCost
discover(query, options?)DiscoverResult1 credit
result(id)DiscoverResultFree
artifacts(q?, { type, limit }){ data: Artifact[] }Free
usage(){ balance, spent, live, … }Free
stream.poll(options)StreamBatchFree
stream.iterate(options)AsyncGenerator<StreamEvent>Free
stream.subscribe(options)StreamSubscriptionFree
stream.list / get / pause / resume / deleteStreamSubscriptionFree
verifyWebhook(input)Promise<boolean>—

Next steps