pvoutput-client
===

[](https://crates.io/crates/pvoutput-client)
[](https://github.com/rust-secure-code/safety-dance/)
[](https://pvoutput-client-c6d1fa.gitlab.io)
[](https://deps.rs/repo/gitlab/Lynnesbian/pvoutput-client)
[](https://gitlab.com/Lynnesbian/pvoutput-client/-/pipelines)
Rust client for the [PVOutput](https://pvoutput.org) API.
```rust,no_run
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](https://gitlab.com/Lynnesbian/pvoutput-client/-/tree/main/examples)
directory.
## Features
- Asynchronous client (powered by [reqwest](https://github.com/seanmonstar/reqwest))
- Support for almost all API endpoints and parameters, including those that require
[donation status](https://pvoutput.org/help/donations.html)
- Exhaustive error handling
- An extensive test suite
- [Rich documentation](https://pvoutput-client-c6d1fa.gitlab.io)
### Unsupported endpoints
Feel free to [open an issue](https://gitlab.com/Lynnesbian/pvoutput-client/-/issues) or
[submit a merge request](https://gitlab.com/Lynnesbian/pvoutput-client/-/merge_requests) if you need support for any of
these endpoints.
- [Join team](https://pvoutput.org/help/api_specification.html#join-team-service)
- [Leave team](https://pvoutput.org/help/api_specification.html#leave-team-service)
- [Register notification](https://pvoutput.org/help/api_specification.html#register-notification-service)
- [Deregister notification](https://pvoutput.org/help/api_specification.html#deregister-notification-service)
In addition, none of the [data services](https://pvoutput.org/help/data_services.html) 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](https://pvoutput-client-c6d1fa.gitlab.io/pvoutput_client/types/response/struct.Response.html) 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`](https://pvoutput-client-c6d1fa.gitlab.io/pvoutput_client/client/struct.Client.html#method.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](https://curl.se/) 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](https://gitlab.com/Lynnesbian/pvoutput-client/-/blob/main/doc/IDIOSYNCRASIES.md) for some
useful tips.
If you want to reference my code, go ahead -- just make sure you're following the licences.