Skip to main content

Advanced Client Configuration

For production applications and advanced use cases, the Rebase Dashboard API client provides several configuration options.

Async Client

For non-blocking API calls, use the async client:
import asyncio
from rebase_dashboard import AsyncRebaseDashboardClient

async def main():
    client = AsyncRebaseDashboardClient(
        api_key="YOUR_API_KEY",
    )

    # Create a dashboard asynchronously
    dashboard = await client.dashboards.create_dashboard(
        name="Async Dashboard"
    )

    print(f"Created dashboard: {dashboard.id}")

# Run the async function
asyncio.run(main())

Error Handling

The SDK provides comprehensive error handling for API responses:
from rebase_dashboard.core.api_error import ApiError

try:
    dashboard = client.dashboards.create_dashboard(
        name="Test Dashboard"
    )
except ApiError as e:
    print(f"Error {e.status_code}: {e.body}")
    # Handle the error appropriately

Timeouts

Configure request timeouts:
# Set default timeout for all requests
client = RebaseDashboardClient(
    api_key="YOUR_API_KEY",
    timeout=30.0  # 30 seconds
)

# Override timeout for specific requests
dashboard = client.dashboards.create_dashboard(
    name="Quick Dashboard",
    request_options={"timeout_in_seconds": 5}
)

Retries

The SDK automatically retries failed requests with exponential backoff:
# Configure retry behavior
dashboard = client.dashboards.create_dashboard(
    name="Retry Test",
    request_options={"max_retries": 3}
)

Custom HTTP Client

For advanced use cases like proxies or custom transports:
import httpx
from rebase_dashboard import RebaseDashboardClient

client = RebaseDashboardClient(
    api_key="YOUR_API_KEY",
    httpx_client=httpx.Client(
        proxies="http://my.proxy.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    )
)

Raw Response Access

Access raw response data including headers:
# Get raw response with headers
response = client.dashboards.with_raw_response.create_dashboard(
    name="Raw Response Test"
)

print(f"Status: {response.status_code}")
print(f"Headers: {response.headers}")
print(f"Data: {response.data}")

Environment Variables

For production deployments, use environment variables:
import os
from rebase_dashboard import RebaseDashboardClient

client = RebaseDashboardClient(
    api_key=os.getenv("REBASE_API_KEY"),
)

Next Steps

Now that you understand advanced configuration, explore these guides:

API Reference

Explore all available endpoints and data structures.

Production Deployment

Learn about production deployment best practices.

Essentials

Learn about datasets and data management.

Weather Integration

Learn about weather data integration.