Skip to main content

Python client for OpenChainBench live crypto infrastructure benchmarks

Project description

openchainbench

Official Python client for OpenChainBench, the live, reproducible benchmark suite for crypto infrastructure (RPC latency, bridge fees, perp venues, oracle deviation, and more).

PyPI version Python versions Downloads License

The data served by openchainbench.com is published under CC-BY-4.0. Attribute with a link back to the benchmark page (pageUrl on every payload).

Install

pip install openchainbench

Requires Python 3.10+.

Quick start

from openchainbench import OpenChainBench

with OpenChainBench() as ocb:
    for bench in ocb.list_benchmarks():
        if bench.leader:
            print(f"{bench.title}: {bench.leader.name} -> {bench.value}")

Fetch one benchmark

from openchainbench import OpenChainBench

with OpenChainBench() as ocb:
    bench = ocb.get_benchmark("bridge-fee")
    print(bench.headline)
    for row in bench.rankings[:3]:
        print(row.slug, row.ms.p50, row.success_rate)

Fetch a time series

from openchainbench import OpenChainBench

with OpenChainBench() as ocb:
    series = ocb.get_series("bridge-fee", range="24h")
    for provider in series.providers:
        print(provider.name, provider.values[-1])

Filter by chain or region

bench = ocb.get_benchmark("network-fees", chain="ethereum")
series = ocb.get_series("network-fees", range="7d", chain="ethereum", region="eu-west")

Error handling

The client maps HTTP responses to a typed exception hierarchy so callers can react to intent rather than status codes.

from openchainbench import (
    OpenChainBench,
    NotFoundError,
    RateLimitError,
    APIUnavailableError,
)

with OpenChainBench() as ocb:
    try:
        ocb.get_benchmark("not-a-real-slug")
    except NotFoundError:
        ...
    except RateLimitError as exc:
        print(f"retry after {exc.retry_after_sec}s")
    except APIUnavailableError:
        # cold cache or Prom blackout, retry later
        ...

API reference

Method Endpoint Returns
list_benchmarks() GET /api/citable list[BenchmarkSummary]
fetch_citable_index() GET /api/citable CitableIndex
get_benchmark(slug, *, chain=None, region=None) GET /api/stat/<slug> Benchmark
get_series(slug, *, range="24h", chain=None, region=None, providers=None) GET /api/series/<slug> Series

All models are immutable dataclasses (frozen=True).

Rate limits

The public API allows 60 requests per minute per IP. The client surfaces HTTP 429 as a RateLimitError with a retry_after_sec attribute.

Citation

If you use the data in a paper, post, or product, please link the benchmark page. The license is CC-BY-4.0. Every payload includes a ready-to-paste quote field that already contains the attribution.

Links

License

MIT. The data fetched from the API stays under CC-BY-4.0; this client license only covers the code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openchainbench-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openchainbench-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file openchainbench-0.1.0.tar.gz.

File metadata

  • Download URL: openchainbench-0.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openchainbench-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d855442988f907f845f7568f2b378909089bf9061819cb94898ae88cb0a38ff1
MD5 8bd36c877404d0b12d2da64fe514d61a
BLAKE2b-256 590fe6360946c1130526a6c0f67300a7eb29b374daef77a77b1d27ca44493f1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for openchainbench-0.1.0.tar.gz:

Publisher: pypi-publish.yml on ChainBench/OpenChainBench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openchainbench-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openchainbench-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openchainbench-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abfe03723d9701b842fcd09851a889169d7f8070bfb757a64a48152a47c094ee
MD5 8d927620b137d37fac950b210fd42fce
BLAKE2b-256 cd17c94c18a25279f7cecf1b81f6072f610c09fc2f67206b90e761fa6ced4d28

See more details on using hashes here.

Provenance

The following attestation bundles were made for openchainbench-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on ChainBench/OpenChainBench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page