# Intuned Client SDK

Owned TypeScript SDK for the Intuned public APIs.

## Installation

### npm

```bash
npm add @intuned/client
```

### pnpm

```bash
pnpm add @intuned/client
```

### bun

```bash
bun add @intuned/client
```

### yarn

```bash
yarn add @intuned/client
```

## Getting Started

To get started, see the [Intuned client API overview](https://docs.intunedhq.com/client-apis/overview).

You will need:

- an API key
- a workspace ID

The SDK uses native `fetch`. In Node.js, use Node 18+ or provide a custom `fetch` implementation.

## Usage

```ts
import { IntunedClient } from "@intuned/client";

const client = new IntunedClient({
  apiKey: process.env["INTUNED_API_KEY"] ?? "",
  workspaceId: "123e4567-e89b-12d3-a456-426614174000",
});

const result = await client.projects.runs.start("my-project", {
  api: "my-awesome-api",
  parameters: { hello: "world" },
});

console.log(result);
```

## Web Tasks

`client.webTasks.run(body)` is a convenience over `webTasks.start` + `webTasks.result`: it starts a Web Task and polls `result` until the task reaches a terminal state (`status === "completed"` or `status === "canceled"`). Branch on `status` and `outcome` to handle the response.

```ts
const terminal = await client.webTasks.run(
  {
    task: "Extract pricing from the homepage",
    startUrl: "https://example.com",
    parameters: {},
    outputSchema: { type: "object" },
  },
  { pollIntervalMs: 5_000 },
);
```
