# Postman and OpenAPI

> The public packeroo API as OpenAPI 3.1 in JSON and YAML, the Postman collection with a sandbox environment, and the import into Insomnia, Bruno and Hoppscotch.

Every file is built at each release from the same contract as the reference. They hold only the public operations and stay at these addresses.

## OpenAPI

| File | Address |
| --- | --- |
| OpenAPI 3.1, JSON | [/openapi.json](https://developers.packeroo.com/openapi.json) |
| OpenAPI 3.1, YAML | [/openapi.yaml](https://developers.packeroo.com/openapi.yaml) |

There is no official SDK. For the operations of today an HTTP client is enough, as the [examples](https://developers.packeroo.com/en/guides/pair-a-table-device/#the-complete-program) show. If you want a typed client anyway, generate it from the OpenAPI file, for example with OpenAPI Generator (needs Java):

```bash
npx @openapitools/openapi-generator-cli generate -i https://developers.packeroo.com/openapi.yaml -g python -o packeroo-client
```

Instead of `python`, use `typescript-fetch`, `csharp`, `php`, `go` or `java` for your language. Generate the client again when an operation is added in the [changelog](https://developers.packeroo.com/en/changelog/).

## Postman

| File | Address |
| --- | --- |
| Collection | [packeroo.postman_collection.json](https://developers.packeroo.com/packeroo.postman_collection.json) |
| Sandbox environment | [packeroo-sandbox.postman_environment.json](https://developers.packeroo.com/packeroo-sandbox.postman_environment.json) |

To send the first request:

1. Download both files.
2. In Postman: **Import**, drop both files in.
3. Choose the environment **packeroo Sandbox** at the top right.
4. Under **Table devices**, open **Ask to pair this device** and send it. Postman makes a new `Idempotency-Key` for every send (`{{$guid}}`).
5. Paste the `token` from the answer into **token** of the environment. From then on every request of the collection sends it as a bearer token.

The environment keeps `token` as a secret, so Postman does not show it openly. Do not share the environment with a token in it.

## Insomnia, Bruno, Hoppscotch

These tools read the OpenAPI file directly:

- **Insomnia:** Import, then "From URL" with `https://developers.packeroo.com/openapi.json`, or the downloaded file.
- **Bruno:** Import Collection, then "OpenAPI V3 Spec" and choose the file.
- **Hoppscotch:** Import, then "OpenAPI" and the file or address.

The base address of the sandbox is `https://api.qm.packeroo.com/api/v1`. Set `User-Agent` to the name of your device, or the API answers `400`.
