| Crates.io | amber-api |
| lib.rs | amber-api |
| version | 1.0.0 |
| created_at | 2025-08-06 23:22:58.49773+00 |
| updated_at | 2025-08-06 23:22:58.49773+00 |
| description | Rust client for Amber Electric's API |
| homepage | |
| repository | https://github.com/JP-Ellis/amber-api |
| max_upload_size | |
| id | 1784438 |
| size | 268,687 |
Add this to your Cargo.toml:
[dependencies]
amber-api = "~1"
use amber_api::Amber;
// Create a client with your API key
let client = Amber::builder()
.api_key("your-api-key-here") // Prefer setting AMBER_API_KEY in an environment variable
.build()?;
// Get all your electricity sites
let sites = client.sites()?;
println!("Found {} sites", sites.len());
// Get renewable energy data for Victoria
let renewables = client.renewables().state("vic").call()?;
println!("Current renewable: {}%", renewables.percentage);
You'll need an API key from Amber Electric. You can provide it in several ways:
export AMBER_API_KEY="your-api-key-here"
Then use the default client:
let client = Amber::default();
let client = Amber::builder()
.api_key("your-api-key-here")
.build()?;
Check out the examples directory for comprehensive usage examples. You can run them directly using Cargo and they will demonstrate various API features.
Most of the examples require that the AMBER_API_KEY environment be set, with the exception of the renewables:
cargo run --example renewables
This library provides access to:
For detailed API documentation, visit the Amber Electric API docs.
We welcome contributions! Please see our Contributing Guide for details on:
Run the test suite:
# Run tests with nextest (faster)
cargo nextest run
# Run integration tests
cargo test --test integration
This project is licensed under the MIT License - see the LICENSE file for details.