MyHospitals API

About the API

The MyHospitals application programming interface (API) provides access to a selection of hospital data, allowing you to get up to date hospital data in portable data formats JSON and CSV.

The API is open and free to use. You can interact with the API to consume hospital data and use it in your own software and systems.

Who is the API for?

The MyHospitals API is mainly for software and data specialists, who can use the API to communicate with AIHW machine-to-machine and acquire data. The API is used by AIHW staff, other government agencies, the private sector, and individuals.

The API is only one way to get access to hospital data. You can also access hospital data on the data downloads page, or by using the interactive visualisations on MyHospitals

What data is available?

The API allows you to make requests from a selection of hospital data. The data is always up to date with the latest releases on MyHospitals. Available data includes:

  • Hospital data – Data on elective surgery, emergency department care, admissions, length of stay, available services, and more.
  • Multi-level data – Data may be available at multiple levels, from the hospital level to aggregate figures at local hospital network (LHN), state or territory, and national levels. Availability can vary across data collections.
  • Geographic data about hospitals – The API offers location data and some mappings for Australian hospitals.

We will continue to load the latest hospital data, and as we continue to develop MyHospitals the API may grow to include more data.

Getting started

Key information for new users

API URL

https://myhospitalsapi.aihw.gov.au/

API calls

To understand and use the MyHospitals API calls:

Use the interactive page to test the API. Add filters or change the response format to return the data you are interested in.

To understand the data that is returned by the API calls, look for the schemas at the bottom of the interactive home page, in the documentation, or in the OpenAPI definition. The schemas provide useful details about the data, including descriptions, types, structures, and relationships within the data.

Response format

Most API calls provide a response in machine readable JSON or CSV format. JSON is returned by default, or you can specify JSON or CSV in the HTTP accept header on an API request:

  • an accept header value of ‘application/json’ returns JSON
  • an accept header value of ‘text/csv’ returns CSV

The JSON responses follow a similar format for all API calls and include metadata information along with the result data. Each JSON response is split into 2 parts:

  • result – this contains the data from the API call and matches the format of the response schema for that call
  • version_information – this is metadata related to the API call and contains:
    • the API version
    • the data version
    • the date the data was uploaded
    • the timestamp of the request

The CSV response format only contains the result information.

Some API calls return downloadable Excel spreadsheets which are structured and formatted in a consistent template.

Versioning

The API version is included within the API URL using the format: /api/{version}/{resource}

The API was developed in line with the National API Design Standards on api.gov.au and each version has been documented according to the OpenAPI 3.0 Specification (formerly known as Swagger) for describing and documenting APIs.

API version Status API definition JSON
v1 Current http://myhospitalsapi.aihw.gov.au/swagger/v1/swagger.json
v0 Deprecated http://myhospitalsapi.aihw.gov.au/swagger/v0/swagger.json

Note that v0 of the API is the old version which was available on the previous myhospitals.gov.au website. If you are still using this version, we continue to provide the old endpoints but encourage you to migrate your applications to use the new version of the API.

Authentication

Currently the API is open and free to use, so it requires no authentication. However, this is subject to change and depending on usage an API key system may be implemented in the future.

Availability

While we strive to make the API available for use at any time, availability is not guaranteed. The API may be temporarily disabled for maintenance or other reasons.

Responsiveness

Most API queries are returned within seconds or milliseconds. Note that responsiveness may be influenced by periods of high API use, or by your internet speed and connectivity.

Caching

The API requests are cached, and the cache is updated daily and whenever new data is published.

Paging

Currently there is no pagination built into the API.

Rate limiting

Currently there is no imposed rate limiting, however API usage will be monitored and limiting may be imposed if issues arise.

Contact

Please use the details on the contact page to request further information or assistance.

License

Material that can be copied or downloaded from this website has been released under a Creative Commons BY 3.9 (CC-BY 3.0) license. Further information can be found on the Copyright page.

Transitioning from the old MyHospitals API

The old MyHospitals API had 3 primary resources:

  • /api/hospitals – a list of public hospitals within MyHospitals
  • /api/indicators – a list of all indicators measured in the MyHospitals website
  • /api/datasets – a custom dataset for a requested set of indicators

These legacy endpoints are still available on the new API and can be found in version 0 of the API.

The legacy endpoints are now:

Where possible, API users are encouraged to migrate their applications to use the new API. Details on the new calls can be found in the OpenAPI definition.

API schemas

The MyHospitals API will be self-explanatory to experienced developers, except for the terminology and data schema it uses. To accelerate your understanding of the API and its data, consult the API schemas for details about the data and descriptions of common terms.

MyHospitals API Schemas (PDF 547kB)

Examples

These examples show the different ways you can access MyHospitals data using the API.