Skip to main content

Introduction

Brew provides official SDKs for TypeScript and Python that make it easy to integrate email marketing capabilities into your applications. The SDKs provide type-safe interfaces, automatic retries, and comprehensive error handling.

Available SDKs

SDKPackageVersionInstall
TypeScriptbrew-sdk0.1.0npm install brew-sdk
Pythonbrew_sdk0.1.0pip install brew_sdk

Features

Both SDKs include:
  • Type Safety - Full type definitions for all API requests and responses
  • Automatic Retries - Built-in retry logic with exponential backoff for transient failures
  • Error Handling - Structured error types for different failure scenarios
  • Configurable Timeouts - Control request timeouts at the client or request level
  • Logging - Debug logging for troubleshooting API calls
  • Rate Limit Handling - Automatic retry on rate limit errors (429)

Rate Limits

Brew enforces 10 requests per second per account. Both SDKs automatically handle rate limiting by:
  1. Retrying rate-limited requests with exponential backoff
  2. Respecting Retry-After headers from the server
If you’re doing bulk operations, use the batch import endpoint (contacts.import.create()) instead of individual API calls.

SDK vs REST API

Use the official SDKs when you want:
  • Type safety - Get compile-time errors and autocomplete in your IDE
  • Less boilerplate - No need to handle HTTP requests, headers, or JSON parsing
  • Automatic retries - Built-in handling for rate limits and transient errors
  • Easier upgrades - SDK updates handle API changes for you
// TypeScript SDK - clean and type-safe
const result = await client.contacts.import.create({
  contacts: [{ email: '[email protected]' }],
});
SDK vs REST API: The SDKs use a streamlined interface that differs from the raw REST API. For example:
  • SDKs use chatId for transactional emails, REST API uses transactionalId
  • SDKs use variables for template data, REST API uses dataVariables
  • SDKs use to for recipients, REST API uses email
This documentation covers the SDK interface. See the API Reference for direct REST API documentation.

Quick Comparison

import BrewSDK from 'brew-sdk';

const client = new BrewSDK({
  apiKey: process.env.BREW_SDK_API_KEY,
});

// Import contacts
const result = await client.contacts.import.create({
  contacts: [
    { email: '[email protected]', firstName: 'John' },
  ],
});

// Send transactional email
await client.send.transactional.send({
  chatId: 'template-id',
  to: '[email protected]',
  variables: { name: 'John' },
});

Requirements

TypeScript SDK

  • TypeScript >= 4.9
  • Node.js 20 LTS or later
  • Also supports: Deno, Bun, Cloudflare Workers, Vercel Edge Runtime

Python SDK

  • Python >= 3.9
  • Works with both synchronous and asynchronous code

Getting Started

1

Get your API key

In Brew, go to Settings → API and click Generate Key.
2

Install the SDK

Choose your language and install the package:
npm install brew-sdk
3

Set up authentication

Set your API key as an environment variable:
export BREW_SDK_API_KEY="your_api_key_here"
4

Start building

Follow the quickstart guide for your SDK:

Need Help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

Search Documentation

Type in the “Ask any question” search bar at the top left to instantly find relevant documentation pages.

ChatGPT/Claude Integration

Click “Open in ChatGPT” at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.