Crate polestar_api

Crate polestar_api 

Source
Expand description

§polestar-api

A lightweight, type-safe Rust wrapper for the Polestar vehicle GraphQL API.

§Quick Start

use polestar_api::PolestarClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = PolestarClient::new("your_username", "your_password")?;
    let telemetry = client.get_telemetry("YOUR_VIN").await?;
    println!("Battery: {:.1}%",
        telemetry.battery.charge_level_percentage.unwrap_or(0.0));
    Ok(())
}

Re-exports§

pub use client::PolestarClient;
pub use error::PolestarError;
pub use error::Result;
pub use models::telemetry::Telemetry;
pub use models::vehicle::Vehicle;

Modules§

auth
Authentication module for Polestar OAuth2/OIDC flow.
client
HTTP client for interacting with the Polestar API.
error
Error types for the Polestar API client.
graphql
GraphQL query definitions for the Polestar API.
models
Data models for Polestar API responses.