---
title: "SDKs"
description: "TypeScript, Python and Rust clients for the API."
---

Official SDKs cover every endpoint, with typed request and response models, bearer authentication and retries.

| Language | Install |
| --- | --- |
| TypeScript | `npm install ptyktos` |
| Python | `pip install ptyktos` |
| Rust | `cargo add ptyktos` |

:::warning
Naming: the SDK packages and their error type still ship under the `ptyktos` name, and their default base URL is the legacy host. Pass the base URL explicitly, as shown below. Package names will change if the SDKs are renamed.
:::

## TypeScript

```ts
import { Ptyktos } from "ptyktos";

const client = new Ptyktos({
  apiKey: process.env.WEBFOLD_API_KEY!,
  baseUrl: "https://api.webfold.ai",
});

const markdown = await client.web.scrape({ url: "https://example.com" });
const papers = await client.arxiv.search({ q: "attention is all you need", n: 10 });
const paper = await client.arxiv.retrieve({ paperId: "1706.03762" });
const transcript = await client.youtube.transcript({ url: "https://youtu.be/dQw4w9WgXcQ" });
```

## Python

```python
import os
from ptyktos import Ptyktos

client = Ptyktos(api_key=os.environ["WEBFOLD_API_KEY"], base_url="https://api.webfold.ai")

markdown = client.web.scrape(url="https://example.com")
papers = client.arxiv.search(q="attention is all you need", n=10)
bookmark = client.bookmarks.create(url="https://example.com", tags=["demo"])
```

## Rust

```rust
use ptyktos::Ptyktos;

let client = Ptyktos::builder(std::env::var("WEBFOLD_API_KEY")?)
    .base_url("https://api.webfold.ai".parse()?)
    .build()?;

let markdown = client.web().scrape("https://example.com").await?;
let papers = client.arxiv().search("attention is all you need", 10).await?;
```

## Namespaces

Each client exposes `web`, `arxiv`, `youtube`, `bookmarks`, `collections`, `usage`, `health`, `documents`, `ocr`, `pii`, `corpus`, `localization` and `computers`. Methods map one-to-one onto the endpoints in this reference.

```ts
const { markdown } = await client.documents.convert({ contentBase64, filename: "report.docx" });
const { method } = await client.ocr.pdf({ contentBase64: pdf, languages: "eng" });
const scan = await client.pii.scan(markdown);
const rows = await client.corpus.build({ records: [{ id: "a", text: markdown }], chunkChars: 2000, redact: true });
const checks = await client.localization.check({ items: [{ source: "Hi {name}", translation: "Hola {name}" }] });
const computer = await client.computers.create({ width: 1280, height: 800 });
```

TypeScript has typed requests and responses for these. The Python and Rust clients return the JSON as dictionaries and `serde_json::Value`. Computer calls that need a gateway capability token take it as `token` (Python, Rust) or `{ token }` (TypeScript).

## Errors and retries

A failed request raises a typed error carrying the HTTP status code and the raw response body. `429` and `5xx` responses are retried up to 3 times with exponential backoff. `4xx` errors are not retried because they indicate a problem with the request.

```ts
import { PtyktosError } from "ptyktos";

try {
  await client.arxiv.search({ q: "test" });
} catch (error) {
  if (error instanceof PtyktosError) {
    console.error(error.statusCode, error.message, error.responseBody);
  }
}
```
