> ## Documentation Index
> Fetch the complete documentation index at: https://docs.darwin.so/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> Use Darwin from a trusted server through REST, an SDK, or the CLI.

REST is the shared contract for Search, Act, Host, Connect, and Account. The JavaScript SDK, Python SDK, and CLI are ways to use that contract; they do not create separate accounts or authorization models.

<Warning>
  Keep API keys and service-account secrets on a trusted server. Browser and mobile applications should use Darwin's user authorization flow, not an embedded server key.
</Warning>

## REST API

The [API Reference](/reference/introduction) documents the live `/api/v2` contract. Each operation identifies its scope, inputs, output, and approval behavior.

Public v1 product routes return `410` with `code: "api_version_retired"`.

For delegated user access, request an OAuth token for the v2 resource `https://api.darwin.so/api/v2`. A token issued for the v1 audience is not a v2 credential. Darwin verifies the application, user grant, requested scopes, and resource on each call.

## JavaScript SDK

Install `@darwinso/sdk` in a server-side JavaScript or TypeScript project:

```bash theme={null}
npm install @darwinso/sdk
```

```typescript theme={null}
import { DarwinClient } from '@darwinso/sdk';

const darwin = new DarwinClient({ token: process.env.DARWIN_API_KEY! });
const account = await darwin.account.getAccount();
```

The generated JavaScript SDK uses the same five families as REST.

## Python SDK

Install `darwin-sdk` and import `darwin_sdk` in server-side Python:

```bash theme={null}
pip install darwin-sdk
```

```python theme={null}
from darwin_sdk import Darwin

darwin = Darwin(token="YOUR_DARWIN_API_KEY")
```

Keep the token in a server-side secret manager. The Python client is generated from the same public OpenAPI document as REST and JavaScript.

## CLI

Install the CLI for local development and account-controlled workflows:

```bash theme={null}
npm install --global @darwinso/cli
darwin --help
```

Create an API key in Developer settings and configure it locally with `darwin configure --api-key "darwin_..."`. For CI, use the `DARWIN_API_KEY` environment variable. The CLI uses the same v2 operations as the API and SDKs.

## Approval

An API key, application credential, or AI client does not bypass account ownership, scopes, spending limits, or approval. Present an approval requirement to the accountable user; do not treat it as a retryable server failure.
