{"library":"metronome-sdk","title":"Metronome SDK","description":"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install metronome-sdk"],"cli":null},"imports":["from metronome.client import Metronome","import metronome.types as types"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom metronome.client import Metronome\nimport metronome.types as types\n\nMETRONOME_API_KEY = os.environ.get('METRONOME_API_KEY', 'YOUR_API_KEY')\n\nif not METRONOME_API_KEY or METRONOME_API_KEY == 'YOUR_API_KEY':\n    print(\"Warning: METRONOME_API_KEY not set. Using placeholder.\")\n    # Example: run in dry-run mode or with a mocked client for testing\n    # For real API calls, ensure API key is set.\n    exit(1)\n\nclient = Metronome(api_key=METRONOME_API_KEY)\n\ntry:\n    # Example: List customers\n    customers = client.customers.list()\n    print(f\"Found {len(customers.items)} customers:\")\n    for customer in customers.items[:3]: # Print first 3 customers\n        print(f\"  ID: {customer.id}, Name: {customer.name}\")\n\n    # Example: Create a new test customer\n    new_customer = client.customers.create(\n        name=\"My Test Customer from SDK\",\n        billing_config=types.BillingConfig(\n            currency=\"USD\",\n            billing_provider_type=types.BillingProviderType.STRIPE,\n            billing_provider_customer_id=\"cus_test_123\",\n        ),\n        external_id=\"my-test-customer-123\"\n    )\n    print(f\"Created new customer with ID: {new_customer.id}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}