prometheus-api-client
A small python api to collect data from prometheus
What it is and what it does
prometheus-api-client is a Python wrapper around Prometheus's HTTP API designed to simplify metrics collection and analysis. It provides the PrometheusConnect class for establishing connections to Prometheus servers, fetching metric lists, and executing instant and range queries. The library handles common tasks like label filtering, time-range chunking, and datetime parsing through its utils module.
Beyond basic API wrapping, the package includes higher-level abstractions: MetricsList and Metric classes for working with result sets as objects, optional DataFrame conversion for data analysis workflows, and plotting support via matplotlib. Core dependencies are minimal (requests and dateparser), with pandas, numpy, and matplotlib available as optional extras. This modular design lets you use just the query layer without pulling in data-science dependencies if your use case doesn't need them.
Use it for:
- Fetch current or historical metrics from a Prometheus server for custom dashboards or alerting logic.
- Aggregate and combine multiple time-series queries programmatically for analysis or reporting.
- Export Prometheus metrics to pandas DataFrames for statistical analysis or machine-learning pipelines.
- Build monitoring automation that queries Prometheus and triggers actions based on metric values.
- Plot time-series data directly from Prometheus for ad-hoc visualization or debugging.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Connects to Prometheus monitoring systems and fetches time-series metrics via HTTP API, with tools for processing, aggregating, and optionally plotting or converting metrics to DataFrames.
Yes. Active maintenance, permissive license, low install friction, no known vulnerabilities, and a straightforward API make this a solid choice for any Python application that needs to query Prometheus. Install the minimal version if you only need API access; add optional extras only if you need DataFrame or plotting support.
Install
prometheus-api-client on PyPI
pip
pip install prometheus-api-clientuv
uv add prometheus-api-clientpoetry
poetry add prometheus-api-clientInstalling prometheus-api-client
Before you install
Low friction: pure Python wheel with only 2 runtime dependencies (requests and dateparser). Active maintenance with a recent release and ongoing repository activity. Optional dependencies for DataFrame and plotting support can be installed separately to minimize footprint.
License in practice
MIT license (permissive). No restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install prometheus-api-client
from prometheus_api_client import PrometheusConnect
prom = PrometheusConnect(url="<prometheus-host>")
metrics = prom.all_metrics()
data = prom.custom_query(query="up")
Verify before relying
- Whether the package supports authentication methods beyond bearer tokens and basic HTTP headers.
- Performance characteristics when querying large time ranges or high-cardinality metrics.
- Compatibility with Prometheus remote storage or federation setups.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — requests, dateparser |
| Maintenance | actively maintained — 123 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,725,574/month — #2,919 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: prometheus_api_client-0.7.2-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
aioprometheusA Prometheus client library for asyncio…
permissive · top 15,000 on PyPI
prometheus-remote-writerSends time-series metrics to…
permissive · top 15,000 on PyPI
prometheus-fastapi-instrumentatorAdds Prometheus metrics collection and exposure…
permissive · top 5,000 on PyPI
opentelemetry-exporter-prometheusExports OpenTelemetry metrics to Prometheus for…
permissive · top 1,000 on PyPI
prometheus-flask-exporterExports HTTP request metrics from Flask…
permissive · top 5,000 on PyPI
py-grpc-prometheusAdds Prometheus metrics collection to gRPC…
unclear · top 5,000 on PyPI
prometheus-clientInstruments Python applications to expose…
permissive · top 1,000 on PyPI
prometheus-client-python-speedupsProvides optional C/Rust-compiled speedups for…
unclear · top 15,000 on PyPI
signalfxPython client library for sending metrics,…
permissive · top 15,000 on PyPI
dtA Python client for the Dynatrace REST API with…
permissive · top 15,000 on PyPI