lemlist-api
v0.1.3
Published
Unofficial typed TypeScript client and helpers for the lemlist API
Downloads
341
Maintainers
Readme
lemlist-api
Unofficial typed TypeScript client and helpers for the lemlist API.
Disclaimer: This project is not affiliated with, endorsed by, or sponsored by lemlist.
Installation
npm install lemlist-api
# or
bun add lemlist-apiQuick Start
import { createLemlistClient, listCampaigns, formatCampaignTable } from "lemlist-api";
const client = createLemlistClient({ apiKey: process.env.LEMLIST_API_KEY! });
// List campaigns
const campaigns = await listCampaigns(client);
console.log(formatCampaignTable(campaigns));
// Get campaign stats
const stats = await getCampaignStats(client, { campaignId: "cam_123" });
console.log(formatCampaignStats(stats));What's Included
This package bundles:
- Typed API client — generated from the lemlist OpenAPI spec, providing full type safety for all 96 endpoints
- Helper functions — business logic for campaigns, leads, enrichment, inbox, schedules, sequences, and more
- Formatting utilities — pretty tables and summaries for terminal output
- Validation — Zod schemas for user input and configuration
- Pagination —
autoPage()utility to collect all pages automatically - CampaignBuilder — fluent builder for deploying complete campaigns
Authentication
Pass your API key directly or use environment variables:
// Direct
const client = createLemlistClient({ apiKey: "your-key" });
// From environment
// Set LEMLIST_API_KEY in your environment
const client = createLemlistClient({ apiKey: process.env.LEMLIST_API_KEY! });Error Handling
The library throws typed errors:
LemlistApiError— general API errorsLemlistAuthError— authentication failures (401)LemlistRateLimitError— rate limit exceeded (429, auto-retried)
import { LemlistApiError, LemlistAuthError } from "lemlist-api";
try {
await listCampaigns(client);
} catch (err) {
if (err instanceof LemlistAuthError) {
console.error("Invalid API key");
}
}License
MIT
