API Usage
Install the types package and start calling the Agori API
TypeScript types
Types are published as a standalone zero-runtime package — install it in any TypeScript project.
npm install @agori/typesThe package contains only type declarations — it adds nothing to your bundle.
Typed fetcher
Copy-paste a fully typed fetcher into your project. The
AreasPostResult type gives you full inference on every field.// lib/agori.ts
import type { AreasPostResult } from '@agori/types'
export async function fetchAreas(
bbox: [number, number, number, number],
sources: string[] = [],
): Promise<AreasPostResult> {
const res = await fetch('/api/points', {
method: 'POST',
headers: {
Authorization: 'Bearer 12345678907812d7c8-1e0d-46d7-88ff-69fa3f04633a',
'Content-Type': 'application/json',
},
body: JSON.stringify({ bbox, sources }),
})
if (!res.ok) throw new Error(`fetchAreas ${res.status}`)
return res.json() as Promise<AreasPostResult>
}