# SDKs

URL: https://neattrim.com/docs/sdks

The TypeScript and Python SDKs for the Neattrim API.

Both SDKs are MIT licensed. They are generated from the OpenAPI document and add the same hand-written helpers.

> **Not on npm or PyPI yet.** `@neattrim/sdk` and `neattrim` are built and tested but not published: they arrive with the first client release, listed in the [changelog](https://neattrim.com/docs/changelog). Until then, call the REST API directly: every tool page and the [API reference](https://neattrim.com/docs/api) has a curl example that works today.

## TypeScript

```bash
npm install @neattrim/sdk
```

```ts
import { readFile } from "node:fs/promises";
import { Neattrim } from "@neattrim/sdk";

const km = new Neattrim({ apiKey: process.env.NEATTRIM_API_KEY });
const bytes = await readFile("clip.mp4");
const file = await km.upload(new Blob([bytes], { type: "video/mp4" }), { fileName: "clip.mp4" });
const job = await km.run("compress_video", { source: file.file_id, target_size_mb: 25 }, { wait: true });
console.log(job.outputs?.[0]?.download_url);
```

It runs on Node 20 and later, Deno, Bun and Cloudflare Workers.

## Python

```bash
pip install neattrim
```

```python
import os

from neattrim import Neattrim

with Neattrim(api_key=os.environ["NEATTRIM_API_KEY"], base_url="https://api.neattrim.com") as km:
    file = km.upload("clip.mp4")
    job = km.run("compress_video", {"source": file["file_id"]}, wait=True)
```

Python 3.11 and later. `AsyncNeattrim` is the async client.

## Helpers in both

- `upload` sends a file as one request or as parallel parts, and can resume.
- `run` starts a job with an idempotency key and waits for the end.
- `verify_webhook` checks a webhook signature.
- Typed errors carry `code`, `fix`, `requestId` and `resetsAt`.

SDK major version equals the API major version. Other languages: generate a client from the OpenAPI document, or call the REST API directly. The [API reference](https://neattrim.com/docs/api) lists every endpoint.
