Developers

Build on Lag.

Official SDKs for Python and TypeScript. Typed, tested, and open source. Ship bots, integrations, and tooling on the Lag API in minutes.

Python SDK

lagclient

Sync and async clients, fully typed with Pydantic v2 models. Python 3.9 through 3.13.

pip install lagclient

Node / TypeScript SDK

@lagapp/sdk

Zero runtime dependencies, ESM first, ships .d.ts declarations. Node 18+ with the global fetch.

npm install @lagapp/sdk
Quickstart

Python

from lagclient import Client

with Client(token="lag_pat_...") as client:
    who = client.identity()
    print(f"Hello, {who.display_name}")

    for server in client.servers.list():
        print(server.name)
Also ships an AsyncClient:
import asyncio
from lagclient import AsyncClient

async def main() -> None:
    async with AsyncClient(token="lag_pat_...") as client:
        me = await client.users.me()
        async for page in client.servers.paginate():
            for server in page.items:
                print(server.name)

asyncio.run(main())

Node / TypeScript

import { LagClient } from '@lagapp/sdk';

const client = new LagClient({ token: 'lag_pat_...' });

const who = await client.identity();
console.log(`Hello, ${who.displayName}`);

const servers = await client.servers.list();
for (const server of servers) {
  console.log(server.name);
}

Requires Node 18+. Uses the global fetch, no extra HTTP client to install.

One client, two credential types

Personal tokens or robot keys.

The SDK accepts a Personal Access Token (lag_pat_*) for code acting on behalf of a user, or a robot API key (lag_robot_*) for bots that act as their own server-scoped identity. Same parameter, same methods, same shapes.

How to create a robot

Robot quickstart

Python
from lagclient import Client

# Robot API keys (lag_robot_*) use the same Client.
with Client(token="lag_robot_abcd1234_...") as bot:
    me = bot.identity()
    print(me.display_name, me.permissions)

    bot.servers.rooms.messages.send(
        me.server_id, "room_id", content="Hello from a robot"
    )
TypeScript
import { LagClient } from '@lagapp/sdk';

// Robot API keys (lag_robot_*) use the same LagClient.
const bot = new LagClient({ token: 'lag_robot_abcd1234_...' });

const me = await bot.identity();
console.log(me.displayName, me.permissions);

await bot.servers.rooms.messages.send(me.serverId!, 'room_id', {
  content: 'Hello from a robot',
});

The SDK detects the token prefix and switches the Authorization scheme automatically. Server-scoped methods route to the right endpoints under the hood.

What's in the box

Fully typed

Every request, response, and error has a type. Your editor does the work so you can ship faster.

Automatic retries

Transient 5xx, 429, and network errors retry with exponential backoff. Retry-After on 429 is honored.

Cursor pagination

Walk large result sets with async iterators. No manual cursor juggling, no off-by-one bugs.

Typed errors

Auth, permission, conflict, rate limit, and server errors are distinct exception classes you can catch.

MIT licensed

Both SDKs are open source under the MIT license. Fork them, audit them, ship them.

Developed in the open

Issues, PRs, and roadmap are public on GitHub. File a bug or ship a feature.

API coverage

Everything you need for REST.

Both SDKs cover the full public REST surface. WebSocket and voice are intentionally out of scope - use the native apps or the CLI for those.

API reference
  • Users & profiles
  • Friends & requests
  • Direct messages
  • Servers
  • Rooms & room messages
  • Events
  • Image uploads
  • Personal access tokens
Resources

Also open source

The Lag CLI is open source too.

Written in Rust. Join voice rooms, send messages, and manage servers straight from your terminal. MIT licensed and built in the open.

Ready to build

Install an SDK and ship your first integration.