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 renewablesThis library provides access to:
- Sites API: Manage your electricity sites
- Renewables API: Access renewable energy data with configurable resolution
- Pricing API: Real-time and forecast pricing information
- Usage API: Historical and current usage data
For detailed API documentation, visit the Amber Electric API docs.
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up the development environment
- Running tests and examples
- Code style and formatting guidelines
- Submitting pull requests
Run the test suite:
# Run tests with nextest (faster)
cargo nextest run
# Run integration tests
cargo test --test integrationThis project is licensed under the MIT License - see the LICENSE file for details.