Recipes
Python Starter
Python starter — `httpx`, retry policy, env-driven auth, trust pre-flight cache. Copy into a service and you have a working client.
Setup#
Use `httpx` for synchronous or async support. Wire the bearer token from env; keep retries explicit; set a sensible timeout.
pip install httpximport os
import httpx
client = httpx.Client(
base_url="https://api.cribscore.co",
headers={"Authorization": f"Bearer {os.environ['CRIBSCORE_API_KEY']}"},
timeout=30.0,
transport=httpx.HTTPTransport(retries=2),
)Search#
List facilities by ZIP. Iterate the response and surface the trust tier alongside every record.
import httpx
response = httpx.get(
"https://api.cribscore.co/v1/facilities",
params={"zip_code": "90003", "limit": 5},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30.0,
)
response.raise_for_status()
payload = response.json()
for facility in payload["data"]:
print(facility["id"], facility["name"], facility.get("safety_score"))Decision memo#
Generate an explainable shortlist. The memo is JSON; render the `summary` field in your UI and use the `shortlist` rows to drive a comparison table.
import httpx
response = httpx.post(
"https://api.cribscore.co/v1/decision/memo",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"geography": "90003",
"child_age_months": 24,
"budget_weekly": 350,
"shortlist_limit": 3,
"priorities": ["safety_score", "license_status", "commute_minutes"],
},
timeout=60.0,
)
response.raise_for_status()
memo = response.json()
print(memo["summary"])
for option in memo["shortlist"]:
print("-", option["facility_id"], option["recommendation"])Trust pre-flight#
Cache the jurisdiction list at startup and gate workflow entry on tier. This is the single most valuable wrapper to add — it prevents non-decision-grade data from leaking into recommendations.
import httpx
response = httpx.get(
"https://api.cribscore.co/v1/trust/jurisdictions",
params={"limit": 25},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30.0,
)
response.raise_for_status()
for jurisdiction in response.json()["data"]:
print(
jurisdiction["state_code"],
jurisdiction["trust_tier"],
jurisdiction["scored_facility_count"],
)