#sdk #api #http

grafana

Ergonomic Rust SDK for Grafana's HTTP API, with async and blocking clients

3 releases

Uses new Rust 2024

0.1.3 Jan 2, 2026
0.1.2 Jan 2, 2026
0.1.1 Jan 2, 2026

#140 in HTTP client

Download history 13/week @ 2026-05-19 53/week @ 2026-05-26 94/week @ 2026-06-02 184/week @ 2026-06-09 49/week @ 2026-06-16 1733/week @ 2026-06-23 302/week @ 2026-06-30 238/week @ 2026-07-07 35/week @ 2026-07-14

2,321 downloads per month

MIT license

435KB
12K SLoC

grafana-rs

Ergonomic Rust SDK for Grafana's HTTP API, with async and blocking clients.

Crates.io  Downloads  Docs.rs  MSRV  CI  Repo Size  License


Install

[dependencies]
grafana = "0.1" # async + rustls (default)

Blocking-only (no Tokio):

[dependencies]
grafana = { version = "0.1", default-features = false, features = ["blocking", "rustls"] }

Native TLS: replace rustls with native-tls (and set default-features = false).

Features

  • async (default): tokio + reqwest.
  • blocking: reqwest::blocking.
  • rustls (default) / native-tls: pick one TLS backend.
  • tracing: request spans.

If you run inside Tokio, call blocking APIs from spawn_blocking or a dedicated thread pool.

Quick start (async)

use grafana::{Auth, Client};

async fn demo() -> Result<(), grafana::Error> {
    let client = Client::builder("https://grafana.example.com")?
        .auth(Auth::bearer("TOKEN"))
        .build()?;

    let health = client.health().get().await?;
    println!("{health:?}");
    Ok(())
}

Quick start (blocking)

use grafana::{Auth, BlockingClient};

fn demo() -> Result<(), grafana::Error> {
    let client = BlockingClient::builder("https://grafana.example.com")?
        .auth(Auth::bearer("TOKEN"))
        .build()?;

    let health = client.health().get()?;
    println!("{health:?}");
    Ok(())
}

Base URL

Pass the Grafana root URL (optionally with a subpath). The client automatically targets /api.

Examples:

  • https://grafana.example.com
  • https://example.com/grafana

API coverage

  • Hand-written wrappers: client.dashboards(), client.folders(), client.user(), ...
  • Generated wrappers: client.openapi() (method-per-operation, keyed by Grafana operationId).
  • Escape hatch: client.raw() for custom requests.

Compatibility

Endpoint wrappers follow the latest Grafana OpenAPI spec (grafana/grafana public/openapi3.json). For full coverage across Grafana versions, use raw() for unwrapped endpoints.

Contract tests (repo)

Run the ignored contract tests against a real Grafana:

# Bearer token auth
GRAFANA_BASE_URL="https://grafana.example.com" GRAFANA_TOKEN="..." \
  cargo test --test contract -- --ignored

# Basic auth
GRAFANA_BASE_URL="http://localhost:3000" GRAFANA_USERNAME="admin" GRAFANA_PASSWORD="admin" \
  cargo test --test contract -- --ignored

Dependencies

~10–28MB
~435K SLoC