This repository contains several "agents" (modular components) that work together to provide a comprehensive Bitvavo cryptocurrency exchange API client. The architecture follows a modern, modular design with clear separation of concerns.
- Name:
Bitvavo(Legacy API) - Description: Original monolithic API client that maintains backward compatibility with the official Bitvavo SDK. Handles both REST and WebSocket operations in a single class with comprehensive method coverage.
- Inputs:
- API credentials (dict with APIKEY/APISECRET)
- Method parameters (dicts for various endpoints)
- WebSocket callback functions
- Outputs:
- REST methods:
dict | listfor success,errordictfor API errors - WebSocket methods: Use callbacks for event handling
- REST methods:
- Config / Env vars:
BITVAVO_APIKEY- API key for authenticationBITVAVO_APISECRET- API secret for signing- Pydantic settings via
BitvavoSettingsandBitvavoApiUpgradedSettings
- Links to code:
src/bitvavo_api_upgraded/bitvavo.py
- Name:
BitvavoClient(Modern Facade) - Description: New modular client facade that provides a clean, testable interface with dependency injection. Orchestrates public/private API endpoints, rate limiting, and HTTP transport.
- Inputs:
BitvavoSettingsconfiguration object- Optional model preferences for response formatting
- Optional default schemas for DataFrame conversion
- Outputs:
- Structured responses via public/private API endpoints
- Support for multiple output formats (dict, Pydantic models, DataFrames)
- Config / Env vars:
- Via
BitvavoSettingsfrombitvavo_client.core.settings - Environment variable loading with
.envsupport
- Via
- Links to code:
src/bitvavo_client/facade.py
- Name:
PublicAPI - Description: Handles all public Bitvavo API endpoints that don't require authentication. Provides market data, ticker information, order books, trade history, and candlestick data.
- Inputs:
- HTTP client instance
- Optional model preferences and schemas
- Endpoint-specific parameters (market symbols, intervals, limits)
- Outputs:
- Market data, tickers, order books, trades, candlesticks
- Support for dict, Pydantic models, and DataFrame outputs
- Config / Env vars:
- Inherits from base HTTP client configuration
- No authentication required (keyless access)
- Links to code:
src/bitvavo_client/endpoints/public.py
- Name:
PrivateAPI - Description: Handles all private Bitvavo API endpoints requiring authentication. Manages account data, balances, orders, trades, deposits, withdrawals, and fees.
- Inputs:
- Authenticated HTTP client instance
- Optional model preferences and schemas
- Endpoint-specific parameters (order details, withdrawal info, etc.)
- Outputs:
- Account information, balances, order responses, trade history
- Transaction and deposit/withdrawal data
- Config / Env vars:
- Requires valid API credentials via HTTP client
- Inherits authentication from transport layer
- Links to code:
src/bitvavo_client/endpoints/private.py
- Name:
HTTPClient - Description: HTTP client for Bitvavo REST API with rate limiting, authentication, and connection management. Handles request signing, rate limit enforcement, and response processing.
- Inputs:
BitvavoSettingsconfigurationRateLimitManagerinstance- API requests with method, URL, and parameters
- Outputs:
- HTTP responses wrapped in Result types
- Rate limit updates and error handling
- Config / Env vars:
- API base URLs, timeouts, retry settings
- Authentication keys and secrets
- Links to code:
src/bitvavo_client/transport/http.py
- Name:
RateLimitManager - Description: Manages rate limiting for multiple API keys and keyless requests. Implements Bitvavo's weight-based rate limiting (1000 points/minute) with automatic throttling and multi-key support.
- Inputs:
- Default rate limit values and buffer settings
- Request weights and API key indices
- Optional custom rate limit strategies
- Outputs:
- Rate limit budget checks and enforcement
- Automatic sleep/retry when limits exceeded
- Config / Env vars:
default_rate_limit- Initial rate limit valuerate_limit_buffer- Safety buffer before hitting limits
- Links to code:
src/bitvavo_client/auth/rate_limit.py
- Name:
AuthenticationAgent(via signing functions) - Description: Handles HMAC-SHA256 signature creation for authenticated Bitvavo API requests. Implements the required signature format with timestamp and body hashing.
- Inputs:
- HTTP method, path, timestamp, body content
- API secret for HMAC signing
- Outputs:
- HMAC-SHA256 signatures for request authentication
- Properly formatted authentication headers
- Config / Env vars:
- API secret key for signature generation
- Links to code:
src/bitvavo_client/auth/signing.py
- Name:
ModelPreferencesystem - Description: Handles response format preferences, allowing users to choose between raw dictionaries, validated Pydantic models, or structured DataFrames for API responses.
- Inputs:
- User preference settings (dict, model, or dataframe)
- Raw API response data
- Optional schema definitions
- Outputs:
- Formatted responses in requested format
- Validated data structures with proper typing
- Config / Env vars:
- Default model preferences in client configuration
- Links to code:
src/bitvavo_client/core/model_preferences.py
- Name:
DataFrameUtils - Description: Provides unified DataFrame support across multiple libraries (pandas, polars, cuDF, etc.) via Narwhals. Converts API responses to DataFrames with proper schemas and type handling.
- Inputs:
- Raw API response data (lists of dicts)
- Schema definitions for DataFrame conversion
- Target DataFrame library preference
- Outputs:
- DataFrames in requested format (pandas, polars, etc.)
- Proper column types and schema validation
- Config / Env vars:
- DataFrame library preferences
- Default schemas for different endpoints
- Links to code:
- Name:
ReturnsAdapter - Description: Provides functional error handling via
returns.result.Resulttypes, mapping HTTP responses and Bitvavo API errors to structured Result monads for clean error propagation. - Inputs:
- HTTP responses from API calls
- Raw response data and status codes
- Outputs:
Result[T, BitvavoError]types for functional error handling- Structured error information with proper typing
- Config / Env vars:
- Error mapping configuration
- Result type preferences
- Links to code:
src/bitvavo_client/adapters/returns_adapter.py
- Name:
PydanticModels(Public/Private) - Description: Provides validated data models for all API endpoints using Pydantic v2. Ensures type safety, data validation, and structured responses with proper field typing.
- Inputs:
- Raw API response dictionaries
- Validation rules and field constraints
- Outputs:
- Validated Pydantic model instances
- Type-safe data structures with IDE support
- Config / Env vars:
- Model validation settings
- Field alias and constraint configurations
- Links to code:
- Name:
SchemaAgent - Description: Defines DataFrame schemas for consistent data structure across different endpoints. Provides default schemas for candlestick data, trade history, order books, and other API responses.
- Inputs:
- API endpoint identifiers
- Data type requirements and constraints
- Outputs:
- Schema definitions for DataFrame conversion
- Type mappings and field specifications
- Config / Env vars:
- Default schema configurations per endpoint
- Links to code:
- Name:
SettingsAgent - Description: Manages configuration via Pydantic Settings with environment variable loading, .env file support, and validation. Handles both legacy and modern client configurations.
- Inputs:
- Environment variables
- .env files
- Direct configuration objects
- Outputs:
- Validated settings instances
- Configuration for all client components
- Config / Env vars:
BITVAVO_APIKEY,BITVAVO_APISECRETBITVAVO_API_URL,BITVAVO_WS_URL- Rate limiting and timeout configurations
- Links to code:
- Name:
WebSocketAppFacade - Description: WebSocket client for real-time market data with automatic reconnection, local order book maintenance, and event-driven callbacks. Part of the legacy Bitvavo class.
- Inputs:
- WebSocket subscription parameters
- Callback functions for different event types
- Connection and reconnection settings
- Outputs:
- Real-time market data events
- Maintained local order books
- Connection status updates
- Config / Env vars:
- WebSocket URL and connection settings
- Reconnection intervals and retry limits
- Links to code:
src/bitvavo_api_upgraded/bitvavo.py(nested class)
- Entry Points: Users interact via either
Bitvavo(legacy) orBitvavoClient(modern) - Request Flow: Client → HTTP Transport → Rate Limiting → Authentication → API Endpoints
- Response Flow: API Response → Model Preference → DataFrame/Pydantic/Dict → User
- Configuration: Settings Agent provides configuration to all other agents
- Error Handling: Returns Adapter provides functional error handling across the stack
The modular design allows for easy testing, extension, and maintenance while providing multiple interfaces for different use cases and preferences.