# SDKs & CLI

> Call Cotlet from Node.js, Python or the terminal: install, authenticate, call any endpoint of any app, handle errors and pages.

Source: https://cotlet.dev/docs/sdks

Docs sections: [Get started](https://cotlet.dev/docs.md) · [REST API](https://cotlet.dev/docs/api.md) · [MCP](https://cotlet.dev/docs/mcp.md) · [SDKs & CLI](https://cotlet.dev/docs/sdks.md) · [Integrations](https://cotlet.dev/docs/integrations.md)

Thin clients over the REST API. They read your key from the environment, retry when an app is busy and turn errors into exceptions.

## Node.js

**Install**

```bash
npm install cotlet
```

**TypeScript**

```ts
import { Cotlet, CotletError } from 'cotlet';

const cotlet = new Cotlet(); // reads COTLET_API_KEY

try {
  const { members } = await cotlet.call('skool', 'list_members', { group: 'yourgroup' });
  console.log(members.length);
} catch (error) {
  if (error instanceof CotletError && error.code === 'AUTH_EXPIRED') {
    console.log('Sign in again:', error.connectUrl);
  }
}
```

Node.js 18 or newer. Works in Bun, Deno and edge runtimes that have `fetch`.

## Python

**Install**

```bash
pip install cotlet
```

**Python**

```python
from cotlet import Cotlet, CotletError

client = Cotlet()  # reads COTLET_API_KEY

try:
    result = client.call("skool", "list_members", {"group": "yourgroup"})
    print(len(result["members"]))
except CotletError as error:
    if error.code == "AUTH_EXPIRED":
        print("Sign in again:", error.connect_url)
```

Python 3.9 or newer. `AsyncCotlet` has the same methods for asyncio.

## Every page of a list

List endpoints return a `next_cursor`. `paginate` follows it for you.

**Node.js**

```js
for await (const page of cotlet.paginate('skool', 'list_members', { group: 'yourgroup' })) {
  console.log(page.members);
}
```

**Python**

```python
for page in client.paginate("skool", "list_members", {"group": "yourgroup"}):
    print(page["members"])
```

## CLI

**Install**

```bash
npm install -g cotlet
cotlet login
```

| Command | What it does |
|---|---|
| `cotlet login` | Saves your API key on this machine. |
| `cotlet apps` | Lists the apps your key has access to. |
| `cotlet endpoints skool` | Lists the endpoints of an app. |
| `cotlet schema skool list_members` | Prints the input schema and an example response. |
| `cotlet call skool list_members --data '{...}'` | Calls an endpoint and prints the JSON result. |

**Terminal**

```bash
cotlet call skool list_members --data '{"group": "yourgroup"}' | jq '.members[].name'
```

Output is JSON, so it pipes into `jq` and shell scripts. `--key` or `COTLET_API_KEY` override the saved key.
