Tesla-API 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tesla-API --version 1.0.0
                    
NuGet\Install-Package Tesla-API -Version 1.0.0
                    
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.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tesla-API" Version="1.0.0" />
                    
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.0
                    
#r "nuget: Tesla-API, 1.0.0"
                    
#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.0
                    
#: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.0
                    
Install as a Cake Addin
#tool nuget:?package=Tesla-API&version=1.0.0
                    
Install as a Cake Tool

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. After getting an access token you can add the Authorization header to the HttpClient. This client is passed into all calls.

You do not need to call the GetAccessToken method in every API request. This is just an example to show the basic setup.

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 List<Vehicle> GetVehicles(string clientID, string clientSecret, string email, string password)
	{
	    TeslaAccessToken accessToken = _teslaAPI.GetAccessToken(_client, clientID, clientSecret, email, password);
	    _client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken.AccessToken}");

	    return _teslaAPI.GetAllVehicles(_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. 
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,308 1/14/2024
1.1.2 456 12/8/2023
1.1.1 1,645 6/4/2023
1.1.0 258 5/18/2023
1.0.8 896 8/8/2022
1.0.7 676 3/24/2022
1.0.6 536 3/23/2022
1.0.5 550 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