The SDK supports Python 3.8+ and provides comprehensive type hints through TypedDict and Pydantic models.
Installation
Install the SDK using pip:Setup and Configuration
Import the SDK
Import the appropriate client based on your needs:
Initialize the Client
Create a new instance of the Straddle client:
Never hardcode your API key directly in your code. Use environment variables or a secure configuration
management system.
Implementation Examples
For account customers (non-platform), the flow is simpler as the account context is inferred from the API key:
Key Features
Type Safety
Built-in type hints with TypedDict for requests and Pydantic models for responses, providing excellent IDE
support and catch errors early.
Async Support
First-class async/await support through the AsyncStraddle client, perfect for high-performance applications.
Automatic Pagination
Built-in support for automatic pagination, making it easy to handle large result sets.
Error Handling
Comprehensive error types and helpful error messages for better debugging and error recovery.
Error Handling
The SDK provides specific exception types for different error cases:Common Error Types
Common Error Types
BadRequestError
(400)UnprocessableEntityError
(422)AuthenticationError
(401)PermissionDeniedError
(403)NotFoundError
(404)RateLimitError
(429)InternalServerError
(>500)
Timeout Configuration
Timeout Configuration
Configure request timeouts:
SDK Requirements
Python Version
Python 3.8 or higher