# Client libraries

> Generate a typed client from the OpenAPI document, or import it into Postman or Insomnia.

Source: https://docs.delivr.no/client-libraries/

Delivr has no official SDKs. The API is plain JSON over HTTPS, and the [OpenAPI 3.1 document](/openapi.yaml) describes every route, field and webhook, so you can generate types and a client for your language. OpenAPI 3.1 support differs between generators; check that yours supports it.

## TypeScript

[`openapi-typescript`](https://openapi-ts.dev) generates types, and `openapi-fetch` gives you a typed `fetch`:

```bash
npm install openapi-fetch
npx openapi-typescript https://docs.delivr.no/openapi.yaml -o src/delivr.d.ts
```

```ts
import createClient from "openapi-fetch";
import type { paths } from "./delivr";

const delivr = createClient<paths>({
  baseUrl: process.env.DELIVR_API_URL,
  headers: { Authorization: `Bearer ${process.env.DELIVR_API_KEY}` },
});

const { data, error } = await delivr.POST("/v1/merchant/quotes", {
  body: {
    pickupExternalStoreId: "oslo-sentrum",
    delivery: { address: { street: "Karl Johans gate 22", postalCode: "0026", city: "Oslo" } },
    parcels: [{ count: 1, weightKg: 4.5, lengthCm: 40, widthCm: 30, heightCm: 20 }],
  },
});
```

Writes other than quotes also need an `Idempotency-Key` header; see [Idempotency](/conventions/idempotency/).

## Other languages

| Language | Generator                                                                            | Command                                                                                                        |
| -------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| Python   | [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) | `openapi-python-client generate --url https://docs.delivr.no/openapi.yaml`                                     |
| Go       | [ogen](https://ogen.dev)                                                             | `go run github.com/ogen-go/ogen/cmd/ogen@latest --target delivr --package delivr --clean openapi.yaml`         |
| Others   | [OpenAPI Generator](https://openapi-generator.tech) (PHP, Java, C#, Ruby and more)   | `npx @openapitools/openapi-generator-cli generate -i https://docs.delivr.no/openapi.yaml -g php -o delivr-php` |

Generated clients do not verify webhook signatures. Use the code in [Verifying signatures](/webhooks/signatures/).

## Postman and Insomnia

Import `https://docs.delivr.no/openapi.yaml` by URL (Postman: **Import**, then paste the link; Insomnia: **Import**, **From URL**). Then:

- set the base URL to `https://driver-staging-api.delivr.no`,
- set bearer auth on the collection with your sandbox key,
- send a fresh UUID as `Idempotency-Key` on writes: `{{$guid}}` in Postman, the UUID template tag in Insomnia. Reuse the same value when you retry the same action.