{"openapi":"3.0.3","info":{"title":"ERstat API","version":"1.0.0","description":"Live Canadian emergency-room data as JSON, across two tiers. The free tier covers closures, reopenings, service disruptions and per-province coverage, for non-commercial use with attribution (a visible link to erstat.ca) and a free API key created in your ERstat account. The commercial tier adds live per-hospital wait times (live and predicted, with a confidence basis on every reading), plus historical and bulk data, under a licence: see https://erstat.ca/licensing. A keyless embeddable widget is available at https://erstat.ca/embed.","termsOfService":"https://erstat.ca/licensing","contact":{"name":"ERstat","url":"https://erstat.ca/developers"}},"externalDocs":{"description":"Developer guide","url":"https://erstat.ca/developers"},"servers":[{"url":"https://erstat.ca"}],"security":[{"ApiKeyHeader":[]},{"ApiKeyQuery":[]}],"paths":{"/api/v1/closures":{"get":{"summary":"Current ER closures and disruptions","description":"All Canadian emergency rooms currently closed or under a service disruption. Cached at the edge for ~60 seconds.","operationId":"listClosures","parameters":[{"name":"province","in":"query","required":false,"description":"Two-letter province/territory code (e.g. ON, NS, AB).","schema":{"type":"string","pattern":"^[A-Za-z]{2}$"}}],"responses":{"200":{"description":"Current closures","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClosuresResponse"}}}},"401":{"description":"Missing or invalid API key. Create a free key at https://erstat.ca/account."},"429":{"description":"Rate limit exceeded (free tier)."}}}},"/api/v1/coverage":{"get":{"summary":"Per-province ER coverage","description":"How many ERs each province has and how many publish a live wait time. Cached for ~5 minutes.","operationId":"getCoverage","responses":{"200":{"description":"Coverage by province","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoverageResponse"}}}},"401":{"description":"Missing or invalid API key. Create a free key at https://erstat.ca/account."},"429":{"description":"Rate limit exceeded (free tier)."}}}},"/api/v1/waits":{"get":{"summary":"Live per-hospital ER wait times (commercial licence)","description":"Current wait time for every tracked emergency room, as a live published reading where the province exposes one and a model prediction elsewhere. Each row carries a `basis` flag (live, predicted, closed or none) so a consumer can degrade gracefully instead of ever showing a wait it cannot stand behind. Requires a commercial API key. Cached at the edge for ~30 seconds.","operationId":"listWaits","parameters":[{"name":"province","in":"query","required":false,"description":"Two-letter province/territory code (e.g. ON, NS, AB).","schema":{"type":"string","pattern":"^[A-Za-z]{2}$"}}],"responses":{"200":{"description":"Current per-hospital waits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WaitsResponse"}}}},"403":{"description":"A commercial licence is required. See https://erstat.ca/licensing."},"429":{"description":"Rate limit exceeded."}}}},"/api/v1/history":{"get":{"summary":"Historical and bulk data (commercial licence)","description":"Historical wait-time and closure data. Requires a commercial API key; response schema and terms are provided with the licence. See https://erstat.ca/licensing.","operationId":"getHistory","responses":{"403":{"description":"A commercial licence is required. See https://erstat.ca/licensing."}}}}},"components":{"securitySchemes":{"ApiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key"},"ApiKeyQuery":{"type":"apiKey","in":"query","name":"key"}},"schemas":{"Closure":{"type":"object","properties":{"id":{"type":"string","example":"ns_rosewayhospital"},"name":{"type":"string","example":"Roseway Hospital"},"city":{"type":"string","example":"Shelburne"},"province":{"type":"string","example":"NS"},"status":{"type":"string","enum":["closed","disruption"]},"message":{"type":"string","nullable":true,"example":"ER closed until 8:00 a.m. due to physician unavailability."},"updated_at":{"type":"string","format":"date-time","nullable":true},"expected_reopen":{"type":"string","format":"date-time","nullable":true}}},"ClosuresResponse":{"type":"object","properties":{"version":{"type":"string","example":"v1"},"generated_at":{"type":"string","format":"date-time"},"attribution":{"type":"string"},"count":{"type":"integer"},"closures":{"type":"array","items":{"$ref":"#/components/schemas/Closure"}}}},"ProvinceCoverage":{"type":"object","properties":{"province":{"type":"string","example":"ON"},"ers":{"type":"integer","description":"Total ERs tracked"},"reporting_live":{"type":"integer","description":"ERs publishing a live wait time"},"pct":{"type":"integer","description":"reporting_live as a percentage of ers"}}},"CoverageResponse":{"type":"object","properties":{"version":{"type":"string","example":"v1"},"generated_at":{"type":"string","format":"date-time"},"attribution":{"type":"string"},"national":{"type":"object","properties":{"ers":{"type":"integer"},"reporting_live":{"type":"integer"}}},"provinces":{"type":"array","items":{"$ref":"#/components/schemas/ProvinceCoverage"}}}},"Wait":{"type":"object","properties":{"id":{"type":"string","example":"on_uhntoronto"},"name":{"type":"string","example":"Toronto General Hospital"},"city":{"type":"string","example":"Toronto"},"province":{"type":"string","example":"ON"},"lat":{"type":"number","nullable":true,"example":43.6579},"lng":{"type":"number","nullable":true,"example":-79.3873},"status":{"type":"string","enum":["open","closed","disruption","unknown"],"description":"Operating status. \"unknown\" when no status signal is published and no wait is available."},"status_message":{"type":"string","nullable":true,"example":"ER closed until 8:00 a.m. due to physician unavailability."},"basis":{"type":"string","enum":["live","predicted","closed","none"],"description":"Source of wait_minutes: a live published reading, a model prediction, closed (no wait applies), or none available."},"wait_minutes":{"type":"integer","nullable":true,"description":"Best current estimate: the live reading when present, else the prediction. Null when closed or no data."},"wait_lower":{"type":"integer","nullable":true,"description":"Lower bound of the wait range for the chosen basis."},"wait_upper":{"type":"integer","nullable":true,"description":"Upper bound of the wait range for the chosen basis."},"live_wait_minutes":{"type":"integer","nullable":true,"description":"The live published reading, if the province exposes one."},"predicted_wait_minutes":{"type":"integer","nullable":true,"description":"Model-predicted wait, available for most ERs."},"predicted_confidence":{"type":"string","enum":["high","moderate","low"],"nullable":true},"updated_at":{"type":"string","format":"date-time","nullable":true,"description":"When the live reading or status was last updated."},"predicted_at":{"type":"string","format":"date-time","nullable":true,"description":"When the prediction was last computed."}}},"WaitsResponse":{"type":"object","properties":{"version":{"type":"string","example":"v1"},"licensed_to":{"type":"string","example":"GreenShield"},"generated_at":{"type":"string","format":"date-time"},"attribution":{"type":"string"},"count":{"type":"integer"},"hospitals":{"type":"array","items":{"$ref":"#/components/schemas/Wait"}}}}}}}