Skip to main content

Installation

Install the Brew SDK using pip:
pip install brew_sdk
Or with your preferred package manager:
pip install brew_sdk

Package Details

PropertyValue
Package Namebrew_sdk
Version0.1.0
LicenseApache-2.0
Repositorygithub.com/GetBrew/brew-python-sdk

Requirements

Python Version

Python 3.9 or higher is required. Supported Python versions:
  • Python 3.9
  • Python 3.10
  • Python 3.11
  • Python 3.12
  • Python 3.13

Dependencies

The SDK automatically installs these dependencies:
PackageVersionPurpose
httpx>=0.23.0, <1HTTP client
pydantic>=1.9.0, <3Data validation
typing-extensions>=4.10, <5Type hints
anyio>=3.5.0, <5Async support
distro>=1.7.0, <2Platform detection
sniffiolatestAsync library detection

Basic Setup

After installation, import and initialize the client:
from brew_sdk import BrewSDK

# Using environment variable (recommended)
client = BrewSDK()

# Or with explicit API key
client = BrewSDK(api_key="your_api_key_here")

Configuration Options

The client accepts these configuration options:
from brew_sdk import BrewSDK

client = BrewSDK(
    # Your API key (defaults to BREW_SDK_API_KEY env var)
    api_key="your_api_key",

    # Override the base URL (defaults to https://brew.new/api)
    base_url="https://brew.new/api",

    # Request timeout in seconds (default: 60)
    timeout=30.0,

    # Maximum retry attempts for failed requests (default: 2)
    max_retries=3,

    # Default headers for all requests
    default_headers={"X-Custom-Header": "value"},
)

Fine-Grained Timeout Control

import httpx
from brew_sdk import BrewSDK

client = BrewSDK(
    timeout=httpx.Timeout(
        60.0,       # Total timeout
        read=5.0,   # Read timeout
        write=10.0, # Write timeout
        connect=2.0 # Connect timeout
    )
)

Async Client

For async applications, use AsyncBrewSDK:
from brew_sdk import AsyncBrewSDK

# Async client
client = AsyncBrewSDK()
Both clients have identical functionality - just use await with the async client.

Custom HTTP Client

Configure the underlying httpx client for advanced use cases:
import httpx
from brew_sdk import BrewSDK, DefaultHttpxClient

client = BrewSDK(
    http_client=DefaultHttpxClient(
        proxy="http://my.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Context Manager

Use the client as a context manager to ensure proper cleanup:
from brew_sdk import BrewSDK

with BrewSDK() as client:
    result = client.contacts.import_.create(
        contacts=[{"email": "[email protected]"}]
    )
# HTTP client is now closed
For async:
from brew_sdk import AsyncBrewSDK

async with AsyncBrewSDK() as client:
    result = await client.contacts.import_.create(
        contacts=[{"email": "[email protected]"}]
    )

Verifying Installation

Verify the SDK is installed correctly:
import brew_sdk
from brew_sdk import BrewSDK

def verify_setup() -> bool:
    """Verify SDK installation and authentication."""
    print(f"brew_sdk version: {brew_sdk.__version__}")
    
    try:
        client = BrewSDK()
        docs = client.send.transactional.documentation()
        print("SDK installed and authenticated successfully!")
        return True
    except brew_sdk.AuthenticationError:
        print("API key is invalid or missing")
        return False
    except Exception as e:
        print(f"Setup verification failed: {e}")
        return False

if __name__ == "__main__":
    verify_setup()

Virtual Environments

We recommend using a virtual environment:
# Create virtual environment
python -m venv venv

# Activate (Linux/macOS)
source venv/bin/activate

# Activate (Windows)
venv\Scripts\activate

# Install SDK
pip install brew_sdk

Next Steps

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.