# SDKs

> Typed TypeScript and Python clients for the OpenWAF API, generated from its OpenAPI contract, one file each, with no dependencies.

OpenWAF has two official API clients, generated from the same OpenAPI contract as the [API reference](https://developers.openwaf.dev/api/):

| SDK | File | Runs on | Dependencies |
|---|---|---|---|
| TypeScript / JavaScript | `openwaf.ts` | Bun, Deno, Node.js with TypeScript type stripping, browsers and any TypeScript toolchain; built on `fetch` | None |
| Python | `openwaf.py` | Python 3.8 or later | None (standard library) |

Each SDK is a single file that you download from the API itself and keep in your project. It has one method per API operation that an API token can call, with typed parameters and answers, and the same change protocol as the dashboard and the CLI: a reason on every write, simulation with a dry run, and the expected version.

**TypeScript**

```ts
import { OpenWAF } from "./openwaf.ts";

const owf = new OpenWAF({ baseUrl: "https://dash.openwaf.dev" }); // token from OPENWAF_TOKEN
const { items = [] } = await owf.listZones();
for (const z of items) console.log(z.name, z.status, z.config_version);
```
**Python**

```py
from openwaf import OpenWAF

owf = OpenWAF(base_url="https://dash.openwaf.dev")  # token from OPENWAF_TOKEN
for z in owf.list_zones()["items"]:
    print(z["name"], z["status"], z["config_version"])
```


- [Get started](https://developers.openwaf.dev/sdk/get-started/): download the SDK, configure a token and list your zones.
- [How the SDKs are generated](https://developers.openwaf.dev/sdk/how-the-sdks-are-generated/): where the files come from and how methods map to API operations.
- [Authentication and configuration](https://developers.openwaf.dev/sdk/authentication/): token, API address and organisation.
- [Writes: reason, simulation and version](https://developers.openwaf.dev/sdk/writes/): the change protocol from code.
- [Error handling](https://developers.openwaf.dev/sdk/error-handling/): `OpenWAFError`, its codes and version conflicts.
- [Pagination](https://developers.openwaf.dev/sdk/pagination/): page through version history and the audit log.
- [Create a DNS record](https://developers.openwaf.dev/sdk/create-a-record/): simulate, review and confirm a change.
- [Purge the cache](https://developers.openwaf.dev/sdk/purge-the-cache/): purge URLs after a deployment.
- [TypeScript reference](https://developers.openwaf.dev/sdk/typescript/): client options, method conventions, errors and types.
- [Python reference](https://developers.openwaf.dev/sdk/python/): constructor, method conventions, errors and return values.
