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