Observed since 21 Oct, 10:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python client for the MyHospitals Data API (Australian Institute of Health and Welfare)
A Rust client for the MyHospitals Data API provided by the Australian Institute of Health and Welfare (AIHW).
Add to your Cargo.toml:
[dependencies]
aihw_myhospitals_api = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
use aihw_myhospitals_api::{Client, new_client};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Using the convenience function
let client = new_client();
// Or with explicit URL
let client = Client::new("https://myhospitalsapi.aihw.gov.au");
// Fetch measure categories
let response = client.get_measure_categories().send().await?;
println!("Found {} categories", response.result.len());
// Fetch datasets
let response = client.get_datasets().send().await?;
for dataset in &response.result {
println!("{}: {} to {}",
*dataset.data_set_name,
dataset.reporting_start_date,
dataset.reporting_end_date
);
}
Ok(())
}
The client provides access to all MyHospitals API endpoints:
| Category | Endpoints | Description |
|---|---|---|
| Caveats | 2 | Data footnotes and suppressions |
| Suppressions | 2 | Legacy suppression data (use Caveats) |
| DataSets | 3 | Grouped data periods |
| Measures | 4 | Health metrics and indicators |
| MeasureCategories | 3 | Measure classifications |
| ReportedMeasures | 4 | Reported measurement forms |
| ReportedMeasureCategories | 3 | Reported measure groupings |
| ReportingUnits | 5 | Hospitals and health services |
| ReportingUnitTypes | 3 | Unit classifications (Hospital, State, National) |
| FlatDataExtracts | 2 | Bulk data retrieval (paginated, max 1000) |
| Downloads | 7 | Excel/XLSX exports |
Run the examples to explore the API:
# Basic usage
cargo run --example basic_usage
# Caveats and suppressions
cargo run --example caveats
# Datasets and data items
cargo run --example datasets
# Measures and categories
cargo run --example measures
# Reporting units (hospitals, states)
cargo run --example reporting_units
# Bulk data extracts with pagination
cargo run --example data_extracts
# Excel download codes
cargo run --example downloads
All API responses are wrapped in an envelope containing:
result - The actual dataversion_information - API version and data version metadatalet response = client.get_reporting_unit_types().send().await?;
// Access the data
for unit_type in &response.result {
println!("{}", *unit_type.reporting_unit_type_name);
}
// Access version info
if let Some(info) = &response.version_information {
println!("API Version: {:?}", info.api_version);
}
Many fields use newtype wrappers for type safety. Dereference with * to access the underlying string:
let response = client.get_measures().send().await?;
for measure in &response.result {
// Use * to dereference the newtype wrapper
println!("Code: {}", *measure.measure_code);
println!("Name: {}", *measure.measure_name);
}
The flat data extract endpoints use skip/top pagination:
use std::num::NonZeroU32;
let response = client
.get_flat_data_extract_by_measure_category_code()
.measure_category_code("ED")
.skip(0) // Start from beginning
.top(NonZeroU32::new(100).unwrap()) // Get 100 items (max 1000)
.send()
.await?;
Download endpoints return ByteStream. Collect to bytes:
use futures::StreamExt;
let response = client
.get_simple_downloads_by_download_code()
.download_code("some-code")
.send()
.await?;
let mut bytes = Vec::new();
let mut stream = response.into_inner();
while let Some(chunk) = stream.next().await {
bytes.extend_from_slice(&chunk?);
}
std::fs::write("output.xlsx", &bytes)?;
# Unit tests
cargo test
# Integration tests (requires network)
cargo test --features integration-tests
Set DEBUG_CODEGEN=1 to see generated code paths:
DEBUG_CODEGEN=1 cargo build
Contributions are welcome! Please feel free to submit a Pull Request.
Releases are automated via GitHub Actions. To create a new release:
Cargo.tomlCHANGELOG.md with the new versiongit commit -am "Release v0.x.y"git tag v0.x.ygit push && git push --tagsThe release workflow will:
Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
Data from the MyHospitals API is licensed under CC-BY 3.0 by the Australian Institute of Health and Welfare.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 5 Feb 2026 | 0 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 21 Oct, 10:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:b0d245f5c13edea5d2b3008856320e7ce96399b14ebea8c37fef8c1b9fe28d21