TypeScript client for ausdata.io
Generate types from /openapi.json with openapi-typescript, then wrap fetch in a 12-line helper. You get autocomplete on every endpoint path and response field.
No npm package yet. Generate types from /openapi.json and use the helper above.
Install
Shell
npm install -D openapi-typescript && npx openapi-typescript https://api.ausdata.io/openapi.json -o ausdata.d.tsCanonical client
TypeScript
import type { paths } from "./ausdata";
const KEY = process.env.AUSDATA_KEY!;
const BASE = "https://api.ausdata.io";
export async function ausdata<P extends keyof paths>(
path: P,
params: Record<string, string | number> = {},
) {
const url = new URL(BASE + (path as string));
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
const r = await fetch(url, { headers: { Authorization: `Bearer ${KEY}` } });
if (!r.ok) throw new Error(`ausdata ${r.status}`);
return r.json() as Promise<
paths[P]["get"]["responses"]["200"]["content"]["application/json"]
>;
}Use it
TypeScript
const snap = await ausdata("/v1/economic-dashboard");
// snap.data.cash_rate is typed as numberNotes
- .Re-run openapi-typescript on each new endpoint release to refresh types.
- .The helper is path-generic. Response types are inferred from the spec.
- .Pin a snapshot of /openapi.json into your repo if you want reproducible builds.
Other SDKs
Get a key and call your first endpoint
500 free calls per month. No credit card.
Get a free API key