humanbaselines
Python client for the Human Crash Baselines API: typed access to human-driver crash-rate baselines by region, route, and filter. Created and maintained by Valgo.
It wraps the /v1 REST API behind the humanbaselines.com tool: construct a client with your key, call typed methods, and get typed results back, with no hand-built JSON and no need to remember the auth header.
bash
pip install humanbaselinespython
from humanbaselines import HumanBaselines
hb = HumanBaselines(api_key="hbk_...") # or set HUMANBASELINES_API_KEY
r = hb.compute(county="travis", outcome="police_reported",
ego_vehicle=["cars", "light_trucks"])
print(r.rate, r.rate_low, r.rate_high) # 4.05 4.0 4.1Features
- Typed end to end. Request filters and results are Pydantic models generated from the API's OpenAPI schema, so the client can't drift from the server.
- Three compute modes. County-wide geofence rates, interstate route-segment rates, and full depot-to-depot trip rates, one method each.
- Filters three ways. Keyword args, a typed
Selectionsmodel, or a plain dict; all validated locally before the request. - Bound definitions. Bind a methodological definition (what counts as a crash, what you baseline against) to a client and reuse it; serialize it to JSON to version and share.
- Runtime discovery.
filters()andregions()return the live catalog of valid values, defaults, and available regions. - Typed errors. Non-2xx responses raise specific exceptions (auth vs. validation vs. warm-up) with the server's field-level detail.
Next steps
- Installation: install and authenticate.
- Quickstart: your first rate in a few lines.
- Reference: every method, argument, and model.
Learn more
For technical details, read the white paper, and reach out to humanbaselines@valgo.ai to submit feedback or request API access.
Outputs are derived statistics only (rates, counts, bounds). See methodology & licensing.