Skip to main content

Quick Start

Install the package and start logging messages in minutes:

Logging Your First Message

Pro tip: Use python-dotenv and store GREENFLASH_API_KEY in a .env file to avoid hard-coding sensitive information.

Async Support

For better performance in async applications:
Performance Note: Install the [aiohttp] extra and pass DefaultAiohttpClient() for optimal async performance.

Type Safety

The SDK provides comprehensive type support for better development experience:
Type Features:
  • Requests: Use TypedDict for type-safe parameters
  • Responses: Pydantic models with .to_dict() and .to_json() methods
  • VS Code: Enable python.analysis.typeCheckingMode = "basic" for inline validation

Handle Errors Gracefully

The SDK provides specific error classes for different failure scenarios:
Available Error Classes:
  • APIConnectionError - Network connection issues
  • RateLimitError - Too many requests
  • APIStatusError - Non-2xx responses with status codes
  • APITimeoutError - Request timeout
  • APIError - Base class for all API errors

Configure Retry Behavior

Automatically retry failed requests with intelligent backoff:
Default Retry Strategy:
  • Retries on connection errors, 408, 409, 429, and 5xx responses
  • Maximum of 2 retries with exponential backoff
  • Configurable globally or per request

Set Request Timeouts

Control how long to wait for responses:
Timeout Behavior:
  • Default timeout: 60 seconds
  • Throws APITimeoutError on timeout
  • Configurable globally or per request

Advanced Features

Access Raw HTTP Response

Get full control over the HTTP response for custom handling:

Configure Logging

Control SDK logging verbosity using environment variables:
Log Levels:
  • error - Only errors (default)
  • info - General information
  • debug - Detailed debugging info
Note: The SDK uses Python’s standard logging module, so you can integrate with your existing logging configuration.