This directory contains examples demonstrating the complete Supermetrics SDK workflow for POC validation.
Demonstrates the full customer onboarding flow from client initialization through authentication, account discovery, and data querying using the synchronous client.
Same workflow as complete_flow.py but using async/await for non-blocking operations.
Demonstrates creating, configuring, and managing custom connectors including secrets and logs. Supports --base-url flag for targeting local dev environments.
Demonstrates the transport features for services acting on behalf of many end users: dynamic token providers, per-request auth_token / headers / timeout overrides on one pooled client, concurrent callers with distinct credentials, with_raw_response for HTTP metadata, and refresh-and-retry on an expired token. See Authentication & Transport.
-
Python 3.11 or higher
python --version # Should show 3.11+ -
Supermetrics API key
- Copy your API key
pip install supermetrics-sdkexport SUPERMETRICS_API_KEY="your_api_key_here"python examples/multi_tenant_flow.pypython examples/complete_flow.pypython examples/async_flow.py# Production
python examples/connector_builder_flow.py
# Local dev (ismtip)
python examples/connector_builder_flow.py --base-url https://{replace-me}
# With team ID
python examples/connector_builder_flow.py --team-id 12345 --base-url https://{replace-me}When you run either example:
- Client initialized - SDK client created
- Login link created - You'll see a URL to visit
- Visit the URL - Authenticate in your browser
- Authentication complete - Script detects completion automatically
- Login details retrieved - Username and data source info displayed
- Accounts discovered - List of available accounts shown
- Query executed - Data query runs for the first account
- Results displayed - Sample data rows printed
Typical execution time: 1-6 minutes (mostly waiting for authentication)
✓ Client initialized
✓ Login link created: https://auth.supermetrics.com/...
Link ID: link_abc123
Status: OPEN
Please visit the login URL to authenticate your data source account.
After authentication, this script will continue automatically.
Waiting for authentication... (0s elapsed)
✓ Authentication complete! Login ID: login_xyz789
✓ Login details retrieved:
Username: user@example.com
Data Source: Google Analytics 4
✓ Found 3 accounts:
- My Website (ID: 12345678)
- Mobile App (ID: 87654321)
✓ Query executed:
Status: completed
Retrieved 7 rows
Sample data (first 5 rows):
Row 1: {'Date': '2024-12-05', 'Sessions': '1234', 'Users': '567'}
...
✅ POC complete! All steps executed successfully.