Expand description
§MyHospitals Data API Client
A Rust client for the MyHospitals Data API provided by the Australian Institute of Health and Welfare (AIHW).
§Features
- Auto-generated from OpenAPI specification using Progenitor
- Async/await support with Tokio
- Builder pattern for ergonomic API calls
- Strongly typed requests and responses
§Quick Start
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 all datasets
let response = client.get_datasets().send().await?;
println!("Found {} datasets", response.result.len());
// Access individual fields (use * to dereference newtype wrappers)
for dataset in &response.result {
println!("{}: {} to {}",
*dataset.data_set_name,
dataset.reporting_start_date,
dataset.reporting_end_date
);
}
Ok(())
}§API Categories
The client provides access to all MyHospitals API endpoints:
- Caveats - Data footnotes and suppressions
- DataSets - Grouped data periods
- Measures - Health metrics and indicators
- MeasureCategories - Measure classifications
- ReportedMeasures - Reported measurement forms
- ReportingUnits - Hospitals and health services
- ReportingUnitTypes - Unit classifications (Hospital, State, National)
- FlatDataExtracts - Bulk data retrieval (paginated, max 1000)
- Downloads - Excel/XLSX exports
§Response Structure
All API responses are wrapped in an envelope containing:
result- The actual dataversion_information- API version and data version metadata
let client = new_client();
let 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);
}§Newtype Wrappers
Many fields use newtype wrappers for type safety. Use * to dereference:
let client = new_client();
let response = client.get_measures().send().await?;
for measure in &response.result {
// Dereference to get the underlying String
println!("Code: {}", *measure.measure_code);
println!("Name: {}", *measure.measure_name);
}Modules§
- builder
- Types for composing operation parameters.
- prelude
- Items consumers will typically use such as the Client.
- types
- Types used as operation parameters and responses.
Structs§
- Byte
Stream - Untyped byte stream used for both success and error responses.
- Client
- Client for MyHospitals Data API
- Response
Value - Typed value returned by generated client methods.
Enums§
- Error
- Error produced by generated client methods.
Constants§
- DEFAULT_
BASE_ URL - Default base URL for the MyHospitals API.
Traits§
- Client
Info - Interface for which an implementation is generated for all clients.
Functions§
- new_
client - Create a new client configured for the production MyHospitals API.