Expand description
§pvoutput-client
Rust client for the PVOutput API.
use pvoutput_client::{Client, types::params::GetSystemParams};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client with your API key and system id.
let client = Client::new("your-api-key", 12345, None, None)?;
// Retrieve all available system information.
let response = client.get_system(GetSystemParams::all()).await?;
let system = response.data.system;
println!("{} is a {} watt system.", system.name, system.size);
// All API requests provide rate limit information.
let rate_limit = response.rate_limit;
println!("You have {} of {} requests remaining.", rate_limit.remaining, rate_limit.limit);
Ok(())
}Further examples can be found in the examples directory.
§Features
- Asynchronous client (powered by reqwest)
- Support for almost all API endpoints and parameters, including those that require donation status
- Exhaustive error handling
- An extensive test suite
- Rich documentation
§Unsupported endpoints
Feel free to open an issue or submit a merge request if you need support for any of these endpoints.
In addition, none of the data services endpoints are supported.
§FAQ
(These are what I assume would be the most frequently asked questions. Nobody has actually asked these yet.)
§How can I check the rate limit?
Every API response returns a
Response struct which
has a rate_limit field.
§What if I just want to check the rate limit without making a request?
There isn’t a way to do that, but you can use an endpoint like
get_ladder
and look at the rate_limit, ignoring the rest of the response.
§How do I tell if the account has donation status?
Check the rate limit response.
If the limit field is 300, the account (probably) has donation status.
The PVOutput API doesn’t provide a way to check this otherwise.
§Why do most endpoints only accept integers? I want to upload floating point values for my energy usage.
The PVOutput API only accepts integer values for most data. You can provide floating point values, but they’ll be rounded to the nearest integer. Try it yourself: use cURL or similar to upload a report with 100.1 watts of usage, and you’ll see the website rounds it to 100.
§I’m making my own PVOutput API client. Is there anything I should know?
Check out IDIOSYNCRASIES.md for some useful tips. If you want to reference my code, go ahead – just make sure you’re following the licences.
Re-exports§
pub use client::Client;pub use types::error::ClientError;pub use types::error::Result;