Tesla-API 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tesla-API --version 1.0.5
                    
NuGet\Install-Package Tesla-API -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tesla-API" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tesla-API" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Tesla-API" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tesla-API --version 1.0.5
                    
#r "nuget: Tesla-API, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tesla-API@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tesla-API&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Tesla-API&version=1.0.5
                    
Install as a Cake Tool

GitHub Workflow Status Release Version Nuget Version Nuget Downloads

Buying a Tesla? Get 1,000 miles of free supercharging with my referral code.

C# Tesla API Client

This is an unofficial .NET 5 client implementation of the Tesla JSON API used by the Android and iOS apps. The API provides functionality to monitor and control the Tesla vehicles remotely.

Tim Dorr API Documentation

API Documentation GitHub

Installation

From Powershell

Nuget-Install 'Tesla-API'

.NET CLI

dotnet add package 'Tesla-API'

Setup

Setup Dependency Injection

In the Startup.cs file, add the following to the ConfigureServices method to allow the TeslaAPI to be dependency injected.

services.AddScoped<ITeslaAPI, TeslaAPI>();
Making a Request

To make a request with the Tesla API, you'll need to create a HttpClient and set the User-Agent header to an identifier for your application.

Authenticating with Tesla

Follow the standard OAuth process as documented by Tim Dorr to get an access token. After getting an access token, add it to the Authorization header on the HttpClient, which is passed into data API calls.

You can use the TeslaAuth package that provides a .net implementation to obtain a (refresh) token.

Example
public class TeslaService
{
	private readonly ITeslaAPI _teslaAPI;
	private readonly HttpClient _client = new HttpClient();

	/// <summary>
	/// Initializes a new instance of the <see cref="TeslaService"/> class.
	/// </summary>
	/// <param name="teslaClient">The TeslaAPI client.</param>
	public TeslaService(ITeslaAPI teslaAPI)
	{
	    _teslaAPI = teslaAPI;
	    _client.DefaultRequestHeaders.Add("User-Agent", "MyApplication");
	}

	/// <summary>
	/// Get all Vehicles in the user's account.
	/// </summary>
	/// <returns>Returns a list of all Vehicles.</returns>
	public async Task<List<Vehicle>> GetVehiclesAsync(string clientID, string clientSecret, string bearerToken)
	{
	    TeslaAccessToken accessToken = await _teslaAPI.GetAccesTokenAsync(_client, clientID, clientSecret, bearerToken);
	    _client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken.AccessToken}");
	    return await _teslaAPI.GetAllVehiclesAsync(_client);
	}
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.3 3,128 1/14/2024
1.1.2 454 12/8/2023
1.1.1 1,644 6/4/2023
1.1.0 258 5/18/2023
1.0.8 895 8/8/2022
1.0.7 675 3/24/2022
1.0.6 535 3/23/2022
1.0.5 549 3/15/2022
1.0.4 551 4/18/2021
1.0.3 2,606 3/1/2021
1.0.2 482 2/6/2021
1.0.1 513 1/21/2021
1.0.0 501 1/3/2021