Skip to main content

exemplar-python-sdk

Python SDK for Exemplar. This package is designed to support multiple Exemplar features over time; currently it includes heartbeat monitor support. The client is a singleton: initialize once with your API key, then send heartbeats from sync or async code.

Install

From PyPI (import name is still exemplar):

pip install exemplar-python-sdk

This SDK is distributed for installation via PyPI only.

Requires Python 3.9+.

Usage

Current supported capability:

  • Heartbeat monitors (sync and async)

1. Initialize once (API key)

Call init at application startup (before any heartbeat). A second init raises RuntimeError.

import exemplar

exemplar.init(api_key="<personal_access_token>")
# optional: exemplar.init(api_key="...", base_url="https://production-api.exemplar.dev")

2a. Simple heartbeat (sync)

Use from a cron job, Celery task, Flask/Django view, or any synchronous code:

import exemplar

exemplar.init(api_key=os.environ["EXEMPLAR_API_KEY"])

exemplar.send_heartbeat(
    "69c3a0754e257b7d18094f9a",
    metadata={"hostname": "worker-01"},
)

This sends POST /api/monitoring/heartbeat with Content-Type: application/json and header X-API-Key: <token>, matching:

curl -sS -X POST 'https://production-api.exemplar.dev/api/monitoring/heartbeat' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: <personal_access_token>' \
  -d '{"monitor_id":"69c3a0754e257b7d18094f9a","metadata":{"hostname":"worker-01"}}'

2b. Background loop (async)

For FastAPI, Starlette, asyncio services, or any framework that runs an async event loop: start a task that heartbeats on an interval (like a cron in the background):

import asyncio
import exemplar

async def main():
    exemplar.init(api_key="...")
    task = asyncio.create_task(
        exemplar.heartbeat_background_loop(
            "69c3a0754e257b7d18094f9a",
            interval_seconds=60.0,
            metadata={"hostname": "worker-01"},
        )
    )
    try:
        # keep your service alive while heartbeat runs
        await asyncio.sleep(3600)
    finally:
        # graceful shutdown
        task.cancel()
        try:
            await task
        except asyncio.CancelledError:
            pass

if __name__ == "__main__":
    asyncio.run(main())

Cancel the task when shutting down. Pass a shared httpx.AsyncClient if you want connection reuse with other HTTP calls.

Development

poetry install
poetry run pytest

API summary

Function Role
exemplar.init(api_key=..., base_url=...) Create singleton (call once)
exemplar.get_client() Access the client after init
exemplar.send_heartbeat(monitor_id, metadata=...) One synchronous POST
exemplar.heartbeat_background_loop(...) Async infinite loop with interval_seconds

Metadata

Release files for exemplar-python-sdk 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exemplar-python-sdk 0.1.5
File Size Uploaded Provenance Actions
exemplar_python_sdk-0.1.5.tar.gz 4.2 kB Without provenance Details for exemplar_python_sdk-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exemplar-python-sdk 0.1.5
File Interpreter ABI Platform Actions
exemplar_python_sdk-0.1.5-py3-none-any.whl Python 3 none any Details for exemplar_python_sdk-0.1.5-py3-none-any.whl

Total release size: 9.6 kB

Release files / exemplar_python_sdk-0.1.5.tar.gz

Download URL exemplar_python_sdk-0.1.5.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
124c276e1c32fa1906478e11f98c6cf2b38591dc25ecc1ae0180175474c670fa
BLAKE2b-256 checksum
How to use checksums
858ee1ae01b2f969712ecb93371fdc8e853ae02fd9b09f3ba9223f0f34daa227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/24.5.0

Release files / exemplar_python_sdk-0.1.5-py3-none-any.whl

Download URL exemplar_python_sdk-0.1.5-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35675b025a5f18c29ce3421f84b0935a90c1ace9b8f2b1fb987b3bbbb719af1f
BLAKE2b-256 checksum
How to use checksums
6ac045803337740c493b9960804f1dd8c223e32e236a4a6f2f8191e943b16ad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Darwin/24.5.0

Security for exemplar-python-sdk 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page