The Posseth.Toyota.Client is a .NET 10 C# client library for interacting with Toyota's MyToyota API.
Posseth.Toyota.Client/
├── src/
│ └── Posseth.Toyota.Client/
│ ├── Interfaces/ # Public API contracts
│ ├── Models/ # API response/request models
│ ├── Services/ # Core business logic
│ ├── Exceptions/ # Custom exception types
│ ├── Configuration/ # Configuration classes
│ └── MyToyotaClient.cs # Main public API entry point
├── tests/
│ └── Posseth.Toyota.Client.Tests/ # Unit and integration tests
├── samples/
│ └── Posseth.Toyota.Demo.ConsoleApp/ # Example usage
└── docs/ # Documentation
The main interface and entry point for all client operations.
Key Features:
- Fluent configuration API (
UseCredentials,UseLogger,UseTimeout, etc.) - Async operations for all API calls
- Full cancellation token support
- Token caching support
Contains all request/response models for the MyToyota API:
VehiclesModel- Vehicle informationElectricResponseModel- EV battery statusLocationResponseModel- Vehicle locationClimateControlResponseModel- Climate control operationsRemoteCommandResponseModel- Remote vehicle commands- And many more...
Internal services handling:
- HTTP communication with the MyToyota API
- Authentication and token management
- Request/response serialization
- Error handling and retry logic
- Async-First: All I/O operations are async with proper
CancellationTokensupport - Fluent Configuration: Builder pattern for easy client configuration
- Type-Safe: Strong typing for all API contracts
- Error Handling: Custom exceptions for different failure scenarios
- Extensibility: Dependency injection friendly architecture
1. Create client with credentials: client.UseCredentials(username, password)
2. Call LoginAsync() to authenticate
3. Tokens are cached (configurable) for subsequent API calls
4. All subsequent API calls use the cached token
GetVehiclesAsync()- List all associated vehiclesGetVehicleAssociationAsync()- Get association details
GetElectricAsync()- EV battery and charging infoGetElectricRealtimeStatusAsync()- Real-time EV status
GetClimateSettingsAsync()- Current climate settingsGetClimateStatusAsync()- Current climate control statusStartClimateControlAsync()- Start climate controlStopClimateControlAsync()- Stop climate controlRefreshClimateStatusAsync()- Refresh climate status
SendRemoteCommandAsync()- Lock, unlock, start engine, etc.
GetLocationAsync()- Vehicle GPS locationGetLockStatusAsync()- Door/trunk lock statusGetHealthStatusAsync()- Vehicle health diagnosticsGetTelemetryStatusAsync()- Telemetry data
GetTripsAsync()- Trip history with optional route dataGetServiceHistoryAsync()- Service and maintenance records
GetNotificationsAsync()- Recent notificationsGetRemoteStatusAsync()- Remote service statusGetDrivingStatisticsAsync()- Eco-scores and statistics
var client = new MyToyotaClient()
.UseCredentials("username", "password")
.UseTimeout(30) // API timeout in seconds
.UseTokenCaching(true) // Cache tokens for reuse
.UseTokenCacheFilename("tokens.json") // Custom cache location
.UseLogger(msg => Console.WriteLine(msg)); // Custom loggingThe client is designed to be used as a singleton or long-lived instance. It is thread-safe for concurrent API calls.
By default, tokens are cached to a file to avoid unnecessary login calls. Configure with:
UseTokenCaching(bool)- Enable/disable token cachingUseTokenCacheFilename(string)- Set custom cache file location
The library throws custom exceptions for different scenarios:
AuthenticationException- Login or token validation failedApiException- API returned an errorOperationCanceledException- Operation was cancelledTimeoutException- Operation exceeded timeout
- Token caching reduces login overhead
- Batch operations where possible
- Use appropriate timeout values for your use case
- Cancel operations that are no longer needed