Skip to main content

BXP — Breathe Exposure Protocol

License BXP Version Spec DOI CI GitHub PyPI npm Discord Governance

BXP is to air quality data what HTTP is to the web — a protocol, not a platform.
A common data language that any sensor, any agency, and any application can speak.
Owned by nobody. Usable by everyone. Free forever.

Try Validator Quick Start Discussions

The Problem · The Solution · Quick Start · Architecture · Health Risk Index · Status · Roadmap · Docs · Contributing


🎯 The Problem

Air pollution causes 7 million premature deaths annually — more than HIV, malaria, and tuberculosis combined (WHO, 2021).

The sensors to measure it exist. The data infrastructure does not.

Every sensor manufacturer, government agency, and research network uses incompatible data formats. A sensor in Accra cannot feed a dashboard in Nairobi. A citizen reading in Delhi cannot contribute to a government pollution map. A researcher in London cannot query a database in Lagos using a single standard format.

The barrier is not hardware. It is data fragmentation.

✨ The Solution

📄 .bxp.json A universal file format for atmospheric exposure data — one schema for any source, any location, any pollutant
🩺 BXP-HRI (experimental) A composite Health Risk Index (0–100) derived from all available agents, weighted by WHO disease-burden data — not clinically validated
🌐 REST API A standard set of endpoints any BXP node must implement, so any client can query any node
🧪 30+ atmospheric agents PM1, PM2.5, PM10, NO₂, O₃, CO, SO₂, benzene, formaldehyde, mold spores, heavy metals, and more — see Appendix A
🔒 Privacy framework SHA-256 hashed identifiers, geohash precision floors, k-anonymisation, cryptographic deletion
🕸️ Federated architecture No central owner — any organisation can run a BXP node on their own infrastructure

📦 Repository Structure

bxp-protocol/
├── SPEC.md                          Protocol specification v2.0
├── CHANGELOG.md                     Development history
├── CONTRIBUTING.md                  Contribution guide
├── GOVERNANCE.md                    Project governance & transparency
├── reference-server/
│   ├── server.py                    FastAPI reference node v2.1
│   ├── database.py                  SQLite persistence layer
│   ├── requirements.txt             Python dependencies
│   └── tests/                       Pytest suite
├── sdk/
│   ├── python/bxp_sdk.py            Python SDK v2.1
│   ├── python/bxp_binary.py         Native binary .bxp codec
│   └── typescript/
│       ├── bxp-sdk.ts               TypeScript SDK
│       └── bxp-binary.ts            Native binary .bxp codec (TS)
├── conformance/                     Cross-implementation golden test vectors
│   ├── vectors/                     17 golden .bxp files (valid + malformed)
│   ├── generate_vectors.py
│   ├── verify_python.py
│   └── verify_typescript.mjs
├── cli/bxp_cli.py                   Command-line tool v2.1
├── integrations/
│   ├── mqtt_bridge.py               MQTT → BXP bridge
│   └── openaq_import.py             OpenAQ v3 API → BXP importer
├── datasets/sample_readings.bxp.json  10 global city readings
├── docs/
│   ├── api_documentation.md           REST API reference
│   ├── developer_guide.md             Developer guide
│   └── protocol_overview.md           Protocol overview
├── postman/BXP_Protocol.postman_collection.json
├── assets/                          README/site imagery
├── Dockerfile
└── docker-compose.yml

🚀 Quick Start

🐳 Docker (Recommended)
# Clone and start in one command
git clone https://github.com/bxpprotocol/bxp-spec.git
cd bxp-spec
docker compose up

Open: http://localhost:5000 — Dashboard | http://localhost:5000/docs — Interactive API | http://localhost:5000/health — Health check

🐍 Python (pip)
# Install SDK
pip install bxp-sdk

# Or run from source
pip install -r reference-server/requirements.txt
cd reference-server && python server.py
📦 Node.js (npm)
# Install SDK
npm install @bxp/sdk   # TypeScript SDK ships in this repository; npm publish pending

Using the Python SDK

from bxp_sdk import write_bxp, read_bxp, calculate_risk, BXPClient

# Calculate health risk from sensor values
risk = calculate_risk(pm25=67.0, no2=31.0, duration="24h", population="sensitive")
print(risk["score"])   # 89.6
print(risk["level"])   # VERY_HIGH

# Write a .bxp.json file
record = write_bxp("accra.bxp.json", {
    "latitude": 5.6037, "longitude": -0.1870,
    "pm25": 47.2, "no2": 18.3, "temp": 29.0,
    "source": "native"  # NEW in v2.0: source classification
})
print(record["bxpHri"])       # 61.2
print(record["bxpHriLevel"])  # HIGH

# Read and verify
data = read_bxp("accra.bxp.json")
print(data["_integrityOk"])   # True

# Submit to a BXP node
client = BXPClient("http://localhost:5000")
result = client.submit(latitude=5.6037, longitude=-0.1870, pm25=47.2)

Using the CLI

# Generate a .bxp.json file
python cli/bxp_cli.py generate --pm25 47.2 --no2 18.3 --lat 5.6037 --lon -0.1870

# Validate against BXP v2.0 spec
python cli/bxp_cli.py validate reading.bxp.json

# Calculate health risk
python cli/bxp_cli.py hri --pm25 67.0 --no2 31.0 --duration 8h --population sensitive

# Submit to a node
python cli/bxp_cli.py submit --server http://localhost:5000 --file reading.bxp.json

# Batch submit a directory of readings
python cli/bxp_cli.py batch-submit --dir ./sensor_data/

# Export as CSV
python cli/bxp_cli.py export reading.bxp.json --format csv

# Generate HTML map
python cli/bxp_cli.py map ./readings/ --output map.html

🎮 Live Demo

Tool Link Description
JSON Validator bxpprotocol.github.io/bxp-spec/validator.html Paste JSON → instant validation + HRI calculation
API Docs (Swagger) http://localhost:5000/docs Interactive OpenAPI 3.0 docs (run server first)
Dashboard http://localhost:5000/ Live city data, maps, health advisories
Postman Collection postman/BXP_Protocol.postman_collection.json Ready-to-use API requests

💡 No install needed — try the validator in your browser right now.

API Examples

# Submit a reading
curl -X POST http://localhost:5000/bxp/v2/readings \
  -H "Content-Type: application/json" \
  -d '{"readings":[{"latitude":5.6037,"longitude":-0.1870,
       "agents":[{"agentId":"PM2_5","value":47.2,"unit":"ug/m3"}]}]}'

# Get latest for a location
curl http://localhost:5000/bxp/v2/locations/s1v0g/latest

# Get live city data
curl http://localhost:5000/bxp/v2/city/accra

# Server health
curl http://localhost:5000/bxp/v2/health

Architecture

BXP uses a five-stage data pipeline:

flowchart LR
    A[📍 LOCATE] --> B[🔎 DETECT] --> C[🧠 INTERPRET] --> D[🛡️ PROTECT] --> E[📊 REPORT]
Stage What Happens
LOCATE Geographic context attached (geohash, coordinates)
DETECT Source classified (Tier 1 phone → Tier 3 reference instrument)
INTERPRET QC applied, units normalised, quality flag assigned
PROTECT BXP-HRI (experimental) calculated, risk level and advice generated
REPORT Stored, queryable, privacy-safe
flowchart TB
    subgraph Sources
        S1[Phone sensor]
        S2[Fixed IoT sensor]
        S3[Reference instrument]
        S4[Community report]
    end
    Sources --> N1[(BXP Node A)]
    Sources --> N2[(BXP Node B)]
    N1 <-->|federated sync – planned| N2
    N1 --> C1[Dashboard / App]
    N2 --> C2[Research query]

No node owns the network — any organisation runs its own, and clients can query across nodes using the same schema and API.

BXP-HRI (experimental) — Health Risk Index

A composite 0–100 score incorporating all available agents simultaneously, weighted by WHO disability-adjusted life year burden data. Not clinically or epidemiologically validated — do not use for medical decisions.

Score Level Guidance
0–20 🟢 CLEAN No restrictions
21–40 🟡 MODERATE Sensitive groups: limit exertion
41–60 🟠 ELEVATED Reduce outdoor exertion
61–75 🔴 HIGH N95 outdoors, close windows
76–90 🟣 VERY HIGH Avoid outdoor activity
91–100 ⚫ HAZARDOUS Health emergency

Current Status

Component Status
BXP v2.0 specification ✅ Complete, with an explicit conformance model (§3.7, §15)
Reference server v2.1 ✅ Core reading/query endpoints implemented, including /nearby and /sync
Python SDK v2.1 ✅ Complete, including native binary format
TypeScript SDK ✅ Complete, including native binary format (new)
CLI tool v2.1 ✅ Complete
MQTT bridge ✅ Complete
OpenAQ importer ✅ Complete — converts OpenAQ v3 data into valid BXP records
Sample dataset ✅ Complete
Binary .bxp format ✅ Implemented in Python and TypeScript; verified byte-for-byte interoperable via conformance/
Conformance test suite ✅ 17 golden vectors, Python + TypeScript both passing
Embedded (C/Arduino/ESP32) 🗓️ Planned, not yet implemented
Federated node sync (/sync) ✅ Implemented (§7 Stage 7) — cursor-based pull replication, deletions propagate as tombstones; trust/reputation/dedup between nodes still unspecified
Nearby-observation query (/nearby) ✅ Implemented (§7 Stage 6, §8.2.1) — relevance-ranked by distance, freshness, quality

Roadmap

Near-term

  • Embedded C reference codec + ESP32/Arduino example, tested against the same conformance vectors as Python/TypeScript
  • PurpleAir (or similar low-cost-network API) importer, following the same trust-preserving pattern as openaq_import.py

v2.1 (planned)

  • Python SDK pip package publication
  • JavaScript/TypeScript npm package
  • Arduino SDK
  • ESP32 SDK
  • BXP-STREAM real-time extension

v3.0 (planned, 2027)

  • Waterborne contamination extension
  • Soil contamination extension
  • IoT mesh networking protocol
  • BXP-HEALTH (HL7 FHIR R4 full mapping)

Limitations

BXP is an independent research project at prototype stage:

  • Federation (/sync) is pull-only replication; node trust/reputation, dedup policy for readings arriving via multiple paths, and conflict resolution are explicitly out of scope for now (SPEC.md §7 Stage 7) — a caller replicating from several peers must handle its own dedup (e.g. by readingId)
  • /sync's "Node Token" auth (SPEC.md §8.2) is a shared-secret placeholder (BXP_NODE_SYNC_TOKEN env var) — real node identity/trust is deferred to a future RFC, same as encryption in the binary .bxp format
  • /nearby's relevance ranking (distance + freshness + quality) is an implementation detail, not a frozen formula — SPEC.md §7 Stage 6 intentionally leaves this open so heuristics can improve without breaking the API shape
  • No embedded (C/Arduino/ESP32) implementation exists yet
  • No third-party has independently implemented the protocol
  • BXP_HRI has not been clinically or epidemiologically validated
  • The reference server is a prototype — not load-tested or security-audited in production
  • The OpenAQ importer's live HTTP path has not been exercised against the real api.openaq.org (built and tested against a realistic offline fixture only, due to this development environment having no outbound network access) — confirm against the live API before relying on it in production

Documentation

Document Location
Protocol specification SPEC.md
API reference docs/api_documentation.md
Developer guide docs/developer_guide.md
Protocol overview docs/protocol_overview.md
Changelog CHANGELOG.md

Contributing

BXP is open source under Apache 2.0. Contributions welcome.

See CONTRIBUTING.md for the RFC process. All specification changes require a 30-day public comment period via GitHub Issues.

GitHub: https://github.com/bxpprotocol/bxp-spec

License

Apache 2.0 — Free to use, implement, modify, and distribute. No royalties. No restrictions. No gatekeepers.

Citation

Specification DOI: https://doi.org/10.5281/zenodo.18906812 Implementation DOI: https://doi.org/10.5281/zenodo.18907003 ORCID: https://orcid.org/0009-0001-4856-4986


The air is public. The data should be too.

Metadata

Release files for bxp-sdk 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bxp-sdk 2.1.0
File Size Uploaded
bxp_sdk-2.1.0.tar.gz 41.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bxp-sdk 2.1.0
File Interpreter ABI Platform
bxp_sdk-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 77.0 kB

Release files / bxp_sdk-2.1.0.tar.gz

Download URL bxp_sdk-2.1.0.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9dc692e3c0c3b18a41d877ef20bb8b3626578a10d2cd6bf800669308cee58f2
BLAKE2b-256 checksum
How to use checksums
8434d7a73dccba642af9f4f8a0c5d88c08c95dd261aee614a99dadb2bd16c074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / bxp_sdk-2.1.0-py3-none-any.whl

Download URL bxp_sdk-2.1.0-py3-none-any.whl
Size 35.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef6491352a49574b11a598536be7abdf3ef0ea5f67da126946a44f484980417f
BLAKE2b-256 checksum
How to use checksums
f710aeb4e7360044453fe97520c65d025ac4570ddb89126d03faacc22019e0cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page