Client Setup¶
The ReZEN Python API client provides multiple ways to authenticate and configure your connection to the ReZEN API platform.
Installation¶
Development Installation
For development or contributing:
Authentication¶
API Key Configuration¶
The client automatically reads from the REZEN_API_KEY
environment variable:
Pass the API key directly to the client:
Security Best Practice
Never hardcode API keys in your source code. Use environment variables or secure configuration management.
Client Initialization¶
Main RezenClient¶
The primary client provides access to all API modules:
from rezen import RezenClient
# Initialize with default settings
client: RezenClient = RezenClient()
# Access specialized API modules
transaction_builder = client.transaction_builder
transactions = client.transactions
teams = client.teams
agents = client.agents
Available Modules
Module | Purpose |
---|---|
client.transaction_builder | Create and configure new transactions |
client.transactions | Manage live transactions and participants |
client.teams | Search and filter team information |
client.agents | Agent search and network management |
Directory Client¶
The Directory API uses a separate client with its own endpoint:
from typing import Dict, List, Any
from rezen import RezenClient, DirectoryClient
# Main client for core APIs
client: RezenClient = RezenClient()
# Separate directory client
directory: DirectoryClient = DirectoryClient()
# Use both in your application
teams: List[Dict[str, Any]] = client.teams.search_teams(status="ACTIVE")
contacts: List[Dict[str, Any]] = directory.search_contacts(name="John Doe")
Configuration Options¶
Base Client Parameters¶
Parameter | Type | Default | Description |
---|---|---|---|
api_key | Optional[str] | None | API authentication key |
base_url | Optional[str] | API default | Custom API endpoint URL |
timeout | Optional[int] | 30 | Request timeout in seconds |
retry_attempts | Optional[int] | 3 | Number of retry attempts |
Advanced Configuration¶
from typing import Dict, str
from rezen import RezenClient
# Custom headers and SSL verification
custom_headers: Dict[str, str] = {
"User-Agent": "MyApp/1.0",
"X-Custom-Header": "custom-value"
}
client: RezenClient = RezenClient(
api_key="your_api_key_here",
verify_ssl=True, # Verify SSL certificates
custom_headers=custom_headers
)
Error Handling¶
Common Authentication Errors
from typing import List, Dict, Any
from rezen import RezenClient
from rezen.exceptions import AuthenticationError, RezenError
try:
client: RezenClient = RezenClient(api_key="invalid_key")
teams: List[Dict[str, Any]] = client.teams.search_teams()
except AuthenticationError as e:
print(f"Invalid API key provided: {e}")
except RezenError as e:
print(f"API error: {e}")
Connection Troubleshooting
- 401 Unauthorized: Check your API key
- 403 Forbidden: Verify API key permissions
- 429 Rate Limited: Implement retry logic with backoff
- 500 Server Error: Check API status or contact support
Best Practices¶
:material-shield-check: Security¶
API Key Security
- Store API keys in environment variables
- Use secrets management in production
- Never commit API keys to version control
- Rotate API keys regularly
:material-speedometer: Performance¶
Optimization Tips
- Reuse client instances across requests
- Implement connection pooling for high-volume applications
- Use appropriate timeouts for your use case
- Handle rate limiting with exponential backoff
:material-bug: Debugging¶
Logging Configuration
Quick Verification¶
Test your client setup with a simple API call:
from typing import List, Dict, Any
from rezen import RezenClient
from rezen.exceptions import RezenError
def test_connection() -> bool:
"""Test connection to the ReZEN API.
Returns:
True if connection successful, False otherwise
Raises:
RezenError: If API request fails
"""
try:
client: RezenClient = RezenClient()
teams: List[Dict[str, Any]] = client.teams.search_teams(page_size=1)
print("✅ Connection successful!")
return True
except RezenError as e:
print(f"❌ Connection failed: {e}")
return False
# Run the test
test_connection()
import os
from typing import Optional
from rezen import RezenClient
def check_environment() -> bool:
"""Check environment configuration for ReZEN API.
Returns:
True if environment is properly configured, False otherwise
Raises:
Exception: If client initialization fails
"""
api_key: Optional[str] = os.getenv('REZEN_API_KEY')
if not api_key:
print("❌ REZEN_API_KEY environment variable not set")
return False
print(f"✅ API key found: {api_key[:8]}...")
try:
client: RezenClient = RezenClient()
print("✅ Client initialized successfully")
return True
except Exception as e:
print(f"❌ Client initialization failed: {e}")
return False
# Check your environment
check_environment()
Next Steps¶
-
:material-hammer-wrench: Transaction Builder
Start creating transactions with the Transaction Builder API
-
:material-account-group: Teams API
Search and manage team information
-
:material-account-tie: Agents API
Access comprehensive agent search and management
-
:material-file-document: Examples
See practical examples and use cases