SDKs & CLI

SDKs & CLI

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

npm install cotlet

TypeScript

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

pip install cotlet

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
for await (const page of cotlet.paginate('skool', 'list_members', { group: 'yourgroup' })) {
  console.log(page.members);
}
Python
for page in client.paginate("skool", "list_members", {"group": "yourgroup"}):
    print(page["members"])

CLI

Install

npm install -g cotlet
cotlet login
CLI commands
CommandWhat it does
cotlet loginSaves your API key on this machine.
cotlet appsLists the apps your key has access to.
cotlet endpoints skoolLists the endpoints of an app.
cotlet schema skool list_membersPrints the input schema and an example response.
cotlet call skool list_members --data '{...}'Calls an endpoint and prints the JSON result.

Terminal

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.