Registry / payments / metronome-sdk

metronome-sdk

JSON →
library4.7.0pypypi✓ verified 83d ago

The Metronome SDK is the official Python library for interacting with the Metronome API, designed for integrating metered billing and usage-based pricing into applications. It provides access to endpoints for managing customers, contracts, usage, invoices, and more. The library is currently at version 4.4.0 and follows a rapid release cadence with frequent updates and bug fixes.

pip install metronome-sdk
INSTALL
IMPORT
SIG · METRONOME-SDK
M
metronome-sdk
paymentspythonv4.7.0
Install
4.2s avg
Import
Disk
35MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 37.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.2s · import 0.000s · 37MB
35MB installed
● package 35MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from metronome import Client
from metronome.client import Metronome
AsyncClient
from metronome import AsyncClient
AsyncMetronome
from metronome import AsyncMetronome

This quickstart initializes the Metronome client using an API key from an environment variable and then demonstrates listing existing customers and creating a new one. Ensure you have a `METRONOME_API_KEY` environment variable set with your actual Metronome API key for successful API calls.

import os from metronome.client import Metronome import metronome.types as types METRONOME_API_KEY = os.environ.get('METRONOME_API_KEY', 'YOUR_API_KEY') if not METRONOME_API_KEY or METRONOME_API_KEY == 'YOUR_API_KEY': print("Warning: METRONOME_API_KEY not set. Using placeholder.") # Example: run in dry-run mode or with a mocked client for testing # For real API calls, ensure API key is set. exit(1) client = Metronome(api_key=METRONOME_API_KEY) try: # Example: List customers customers = client.customers.list() print(f"Found {len(customers.items)} customers:") for customer in customers.items[:3]: # Print first 3 customers print(f" ID: {customer.id}, Name: {customer.name}") # Example: Create a new test customer new_customer = client.customers.create( name="My Test Customer from SDK", billing_config=types.BillingConfig( currency="USD", billing_provider_type=types.BillingProviderType.STRIPE, billing_provider_customer_id="cus_test_123", ), external_id="my-test-customer-123" ) print(f"Created new customer with ID: {new_customer.id}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingThe `minimum_config` field was removed from Rate and Override schemas.
fix
Remove `minimum_config` from any Rate or Override objects in your API requests (e.g., when creating/editing contracts, plans, or prices). Review your contract and pricing configurations.
affects: >=4.3.0
breakingThe `priority` parameter and response field were removed from contract-related API endpoints.
fix
Remove `priority` from any parameters sent when creating or updating contracts, and adjust code that expects `priority` in contract responses.
affects: >=4.2.0
breakingThe `use_list_prices` field was removed from Rate objects.
fix
Update your API calls and data models to no longer include or expect the `use_list_prices` field on Rate objects, particularly when defining or updating pricing plans.
affects: >=4.0.0
breakingThe `customer_id` parameter was removed from preview events requests.
fix
When calling the preview events API, ensure you are no longer passing `customer_id` as a request parameter.
affects: >=3.0.0
breakingThe Preview Events API changed its response structure to return a list of invoices instead of a single invoice object.
fix
If your code assumes a single invoice object from the Preview Events API, update it to iterate over the returned list of invoices, even if it expects only one.
affects: >=2.0.0
breakingPagination support was added to many list endpoints (e.g., Customers, Invoices, Commits, Credits, Usage).
fix
Update calls to affected list endpoints (e.g., `client.customers.list()`) to correctly handle pagination by checking `response.next_page` and `response.items` for results. Direct access to `.items` will only provide the current page's results.
affects: >=1.0.0
Upgrade
Version history
4.7.0latest on PyPI · released May 29, 2026
Audit
Dependencies
pythonrequiredRequired for execution
Agent activity
32 hits · last 30 days
node
28
Resources
metronome-sdk — pip install metronome-sdk · libregistry