skillfed

prometheus-api-client

A small python api to collect data from prometheus

prometheus-api-client v0.7.2 2.7M downloads/30d#2,919 on PyPI277
Permissive license Active released

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-client

uv

uv add prometheus-api-client

poetry

poetry add prometheus-api-client

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.13

Tags

prometheus metrics clientprometheus http api wrapperfetch prometheus time series dataprometheus query libraryprometheus monitoring integrationprometheus metrics processingprometheus data aggregation
prometheusmetrics-collectiontime-series

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

aioprometheus

A Prometheus client library for asyncio…

permissive · top 15,000 on PyPI

prometheus-remote-writer

Sends time-series metrics to…

permissive · top 15,000 on PyPI

prometheus-fastapi-instrumentator

Adds Prometheus metrics collection and exposure…

permissive · top 5,000 on PyPI

opentelemetry-exporter-prometheus

Exports OpenTelemetry metrics to Prometheus for…

permissive · top 1,000 on PyPI

prometheus-flask-exporter

Exports HTTP request metrics from Flask…

permissive · top 5,000 on PyPI

py-grpc-prometheus

Adds Prometheus metrics collection to gRPC…

unclear · top 5,000 on PyPI

prometheus-client

Instruments Python applications to expose…

permissive · top 1,000 on PyPI

prometheus-client-python-speedups

Provides optional C/Rust-compiled speedups for…

unclear · top 15,000 on PyPI

signalfx

Python client library for sending metrics,…

permissive · top 15,000 on PyPI

dt

A Python client for the Dynatrace REST API with…

permissive · top 15,000 on PyPI