API
The API runs the same calculator as the website. Each successful POST /api/v1/calculate uses one credit
from your account; rejected input costs nothing. Create a key on your account page.
Authentication
Authorization: Bearer pfu_...
Endpoints
GET /api/v1/fixtures— fixture list and allowed option values (no key needed)POST /api/v1/calculate— run a calculation (1 credit)GET /api/v1/account— email and credit balanceGET /api/v1/usage?limit=50&before=ID— usage list, newest firstGET /api/v1/usage/ID— one saved calculation, with request and result
Example
curl -s https://plumbingfixtureunits.com/api/v1/calculate \
-H "Authorization: Bearer $PFU_KEY" -H "Content-Type: application/json" \
-d '{
"fixtures": [
{"fixture": "bathroom_group", "occupancy": "private", "supply": "flush_tank", "count": 12},
{"fixture": "kitchen_sink", "occupancy": "private", "supply": "faucet", "count": 12}
],
"system": "flush_tank",
"continuous_gpm": 0,
"side": "total",
"tube_type": "L", "service": "cold", "c": 140,
"pressure": {"street_psi": 55, "rise_ft": 25, "developed_length_ft": 300,
"fixture_min": "flushmate_504", "meter_size": "2"}
}'
side is what the pipe carries: total (hot + cold, the default), cold or
hot. Hot-only and cold-only lines use ¾ of the fixture units.
pressure is optional. When present, give either fixture_min (a listed key) or
fixture_min_psi, and either meter_size, meter_loss_psi, or neither (no meter).
Drainage example
curl -s https://plumbingfixtureunits.com/api/v1/calculate \
-H "Authorization: Bearer $PFU_KEY" -H "Content-Type: application/json" \
-d '{
"method": "drainage",
"slope": "1/4",
"wc_rule": {"wc_on_3in": 3},
"runs": [
{"id": "Building drain", "type": "building_drain", "drains_into": null, "fixtures": []},
{"id": "Branch A", "type": "branch", "drains_into": "Building drain",
"fixtures": [{"fixture": "bathroom_group", "occupancy": "private", "count": 2},
{"fixture": "custom", "name": "Clothes washer", "dfu": 3, "count": 1,
"basis": "local code table"}]}
],
"vents": {"planned": ["2", "2"], "method": "diameter_sum"}
}'
Each run lists the fixtures connected directly to it and the run it drains into; loads add up downstream.
Size = the larger of the BMS 66 fixture-unit table size and the WC rule (false turns the rule off), and never smaller
than a run feeding it. Fixtures not in BMS 66 Table 803 go in as custom with a rating and its basis. 1 credit per drainage
calculation, separate from water.
Responses
- 200 —
{"usage_id", "credits_remaining", "result"}. The result carries version, time, sources, low-flow note and disclaimer. - 400 —
{"error": "plain-English reason", "charged": false} - 401 — missing or bad API key
- 402 — out of credits