# Getting Started

Source: https://docs.paradev.com/sdk/getting-started

Drive Paradev programmatically from any TypeScript or JavaScript codebase.

> **Warning:** The SDK is in early alpha. It is not meant for production use and may be removed in the future. Stay on the latest version (`@superset_sh/sdk@latest`) while we iterate.

The Paradev TypeScript SDK manages workspaces, tasks, projects, and automations from code. Common uses:

* **Bulk task management**: script the creation, triage, or cleanup of tasks across one or many projects.
* **Integrations**: sync tasks to/from your CRM, issue tracker, or internal tools.
* **Provisioning**: spin up workspaces on a developer's machine when an issue is opened, a PR is reviewed, or a customer ticket lands.
* **On-demand agents**: kick off a recurring automation off-schedule when a webhook fires.

The SDK is fully typed and works in Node, Bun, and Deno. It also runs in browsers, but **do not ship `sk_live_…` keys to a frontend**: they are long-lived and grant full org access. From a browser, call a server proxy that holds the key.

## Install

**npm**

```bash
npm install @superset_sh/sdk
```

**pnpm**

```bash
pnpm add @superset_sh/sdk
```

**yarn**

```bash
yarn add @superset_sh/sdk
```

**bun**

```bash
bun add @superset_sh/sdk
```

Stay on the **latest version** rather than pinning. New methods get added; existing ones do not change shape without a version bump and a changelog note.

## Get an API key

1. Open the [Paradev desktop app](https://paradev.com/download) → **Settings → API Keys** → **Create**. The key starts with `sk_live_…`. Copy it now. It is shown only once.
2. Note your **organization ID**. Find it in the org switcher inside the desktop app.

```bash
export SUPERSET_API_KEY=sk_live_…
export SUPERSET_ORGANIZATION_ID=…
```

## Create the client

```ts
import Superset from '@superset_sh/sdk';

const client = new Superset();
// reads SUPERSET_API_KEY and SUPERSET_ORGANIZATION_ID from env
```

Every resource works the same way:

```ts
// Create a task
const task = await client.tasks.create({
  title: 'Wire up auth',
  priority: 'high',
});

// Update it
await client.tasks.update({ id: task.id, statusId: '<uuid>' });

// Look one up by id or slug
const got = await client.tasks.retrieve('SUPER-172'); // returns null if missing

// Find tasks with rich filters
const urgent = await client.tasks.list({
  priority: 'urgent',
  search: 'auth',
  creatorMe: true,
});

// Inspect what else you have: projects and workspaces are host-owned
const [host] = await client.hosts.list();
if (!host) throw new Error('No hosts registered; run `paradev start` on a machine');
const projects = await client.projects.list({ hostId: host.id });
const automations = await client.automations.list();

// Trigger an automation off-schedule
await client.automations.run('<automation-id>');

// Create a workspace on a developer's machine
await client.workspaces.create({
  hostId: '<machine-id>',
  projectId: '<project-id>',
  name: 'fix-auth-bug',
  branch: 'fix/auth',
});
```

See the [reference](https://docs.paradev.com/docs/sdk/reference) for every method, parameter, and return type.

## Configuration

Configure the client explicitly instead of (or with) the env vars:

```ts
const client = new Superset({
  apiKey: 'sk_live_…',
  organizationId: '…',
  timeout: 60_000,            // default: 60s per request
  maxRetries: 2,              // default: 2 retries with exponential backoff
  logLevel: 'warn',           // 'off' | 'error' | 'warn' | 'info' | 'debug'
});
```

The client retries automatically on network errors and 429/5xx responses.

## Handling errors

The SDK throws typed errors for any non-success response:

```ts
import Superset, { APIError, NotFoundError, RateLimitError } from '@superset_sh/sdk';

const client = new Superset();

try {
  await client.tasks.create({ title: '' });
} catch (err) {
  if (err instanceof RateLimitError) {
    // 429: already retried up to maxRetries; back off further if you keep hitting it
  } else if (err instanceof NotFoundError) {
    // 404
  } else if (err instanceof APIError) {
    // anything else: err.status, err.headers, err.error (the parsed body)
    console.error(`Paradev returned ${err.status}:`, err.error);
  }
}
```