| Crates.io | polestar-api |
| lib.rs | polestar-api |
| version | 0.1.0 |
| created_at | 2025-11-22 01:11:18.876688+00 |
| updated_at | 2025-11-22 01:11:18.876688+00 |
| description | A lightweight Rust wrapper for the Polestar vehicle GraphQL API |
| homepage | https://github.com/camerondurham/polestar-api-rs |
| repository | https://github.com/camerondurham/polestar-api-rs |
| max_upload_size | |
| id | 1944572 |
| size | 146,696 |
A lightweight, type-safe Rust wrapper for the Polestar vehicle GraphQL API.
Disclaimer: This library is not affiliated with nor supported by Polestar.
Add this to your Cargo.toml:
[dependencies]
polestar_api = "0.1"
tokio = { version = "1", features = ["full"] }
use polestar_api_rs::PolestarClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with your Polestar account credentials
let client = PolestarClient::new("your_email@example.com", "your_password")?;
// Fetch vehicle telemetry
let telemetry = client.get_telemetry("YOUR_VIN").await?;
println!("Battery: {:.1}%",
telemetry.battery.charge_level_percentage.unwrap_or(0.0));
Ok(())
}
The client authenticates using your Polestar account credentials (username and password). The library handles the web-based login flow to obtain access tokens from the Polestar authentication service.
Note: Authentication implementation is currently in progress. The client accepts username and password credentials which will be used to authenticate with the Polestar API. See the pypolestar reference implementation for examples of the authentication flow.
Security: Never commit credentials to version control. Use environment variables:
export POLESTAR_USERNAME="your_email@example.com"
export POLESTAR_PASSWORD="your_password"
export POLESTAR_VIN="your_vin"
let client = PolestarClient::new("user@example.com", "password")?;
let telemetry = client.get_telemetry("VIN").await?;
if let Some(charge) = telemetry.battery.charge_level_percentage {
println!("Battery: {:.1}%", charge);
}
if let Some(status) = telemetry.battery.charge_status {
println!("Status: {}", status);
}
let client = PolestarClient::new("user@example.com", "password")?;
let vehicle = client.get_vehicle("VIN").await?;
println!("Model: {}", vehicle.content.model.name.unwrap_or_default());
println!("Market: {}", vehicle.market.unwrap_or_default());
See the examples/ directory for more complete examples.
Run all tests:
cargo test
Run integration tests (requires credentials):
export POLESTAR_USERNAME="your_email@example.com"
export POLESTAR_PASSWORD="your_password"
export POLESTAR_VIN="your_vin"
cargo test --test integration_tests
Use the test harness CLI:
cargo run --example test_harness --features cli -- \
--username "$POLESTAR_USERNAME" \
--password "$POLESTAR_PASSWORD" \
--vin "$POLESTAR_VIN" \
--endpoint all
Current Version: 0.1.0 (Planning Phase)
This project is in active development. The current release includes:
See PLAN.md for the complete roadmap.
Contributions are welcome! Please open an issue or pull request on GitHub. Contribution guidelines will be added in a future release.
Dual-licensed under either of:
at your option.
This is an unofficial, community-maintained wrapper for the Polestar API. It is not affiliated with, endorsed by, or supported by Polestar or Volvo Car Corporation.