diff --git a/README.md b/README.md index 15d6e9f53..b7bebbf5c 100644 --- a/README.md +++ b/README.md @@ -1,100 +1,4 @@ -# Metronome Python API library - - -[![PyPI version](https://img.shields.io/pypi/v/metronome-sdk.svg?label=pypi%20(stable))](https://pypi.org/project/metronome-sdk/) - -The Metronome Python library provides convenient access to the Metronome REST API from any Python 3.9+ -application. The library includes type definitions for all request params and response fields, -and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx). - -## MCP Server - -Use the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. - -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) - -> Note: You may need to set environment variables in your MCP client. - -## Documentation - -The REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). The full API of this library can be found in [api.md](api.md). - -## Installation - -```sh -# install from PyPI -pip install metronome-sdk -``` - -## Usage - -The full API of this library can be found in [api.md](api.md). - -```python -import os -from metronome import Metronome - -client = Metronome( - bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted -) - -client.v1.usage.ingest( - usage=[ - { - "transaction_id": "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72", - "customer_id": "team@example.com", - "event_type": "heartbeat", - "timestamp": "2024-01-01T00:00:00Z", - "properties": { - "cluster_id": "42", - "cpu_seconds": 60, - "region": "Europe", - }, - } - ], -) -``` - -While you can provide a `bearer_token` keyword argument, -we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/) -to add `METRONOME_BEARER_TOKEN="My Bearer Token"` to your `.env` file -so that your Bearer Token is not stored in source control. - -## Async usage - -Simply import `AsyncMetronome` instead of `Metronome` and use `await` with each API call: - -```python -import os -import asyncio -from metronome import AsyncMetronome - -client = AsyncMetronome( - bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted -) - - -async def main() -> None: - await client.v1.usage.ingest( - usage=[ - { - "transaction_id": "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72", - "customer_id": "team@example.com", - "event_type": "heartbeat", - "timestamp": "2024-01-01T00:00:00Z", - "properties": { - "cluster_id": "42", - "cpu_seconds": 60, - "region": "Europe", - }, - } - ], - ) - - -asyncio.run(main()) -``` +اا``` Functionality between the synchronous and asynchronous clients is otherwise identical.