Typed clients
The API is described by an OpenAPI 3 document, the same one the reference is built from. Generators turn it into a client with every endpoint, parameter and response typed, so your editor completes them and catches mistakes before you run anything.
The document is served by every instance, matching the version it runs:
https://loomkeep.app/api/v1/openapi.jsonOn a self-hosted instance, use your own address. Regenerate the client after
an upgrade to pick up new fields: within v1, they are only ever
added.
openapi-typescript generates the types, and
openapi-fetch is a small fetch
wrapper that uses them.
-
Generate the types, and install the client:
Terminal window npx openapi-typescript https://loomkeep.app/api/v1/openapi.json -o loomkeep.d.tsnpm install openapi-fetch -
Call the API. Paths, parameters and responses are checked against the document:
import createClient from "openapi-fetch";import type { paths } from "./loomkeep";const loomkeep = createClient<paths>({baseUrl: "https://loomkeep.app",headers: { Authorization: `Bearer ${process.env.LOOMKEEP_API_KEY}` },});const { data, error } = await loomkeep.GET("/api/v1/library", {params: { query: { phase: ["IN_PROGRESS"], limit: 10 } },});if (error) throw new Error(error.code ?? error.message);for (const entry of data.items) console.log(entry.work.title);
openapi-python-client generates a package with typed models and one function per endpoint.
-
Generate the package:
Terminal window pipx run openapi-python-client generate \--url https://loomkeep.app/api/v1/openapi.json -
Install the folder it creates (
pip install ./<folder>), then import it: the generatedREADME.mdshows the client to create with your key, and one module per endpoint.
OpenAPI Generator covers about fifty languages: Go, Java, Kotlin, C#, Rust, Swift, PHP, Ruby…
npx @openapitools/openapi-generator-cli generate \ -i https://loomkeep.app/api/v1/openapi.json \ -g go -o loomkeep-clientReplace go with your language’s generator, from
its list.