Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Wiki REST API Tools and Apps

Wiki

Member
Mar 21, 2016
34
174
  • | This is a WikiPost. Members with appropriate permissions may edit.
This is a simple user contributed list of tools and applications that implement the unofficial Tesla Model S REST API
Programming Libraries by Language - These toolkits should help developers get started in the language of their choice.
Python - PyTesla or Teslajson
JavaScript - TeslaMS and TeslaJS
Java - TeslaClient

C#/.Net - Teslalib
Ruby - tesla-api
PHP/MySQL - Tesla Mobile

Mobile Applications - Tesla provides official mobile apps for Android and Apple iOS

Windows Mobile - Tesla Connect, and Tesla Companion
Windows 10 Desktop/Phone/Xbox - Tesla Control
BlackBerry - Model S for Blackberry

Desktop Applications - Download and run these on your laptop, home, or office computer to check up on, and control your car without the need to use your phone

VisibleTesla - runs on any computer with Java
Tapp - MacOS Tesla Client

Basic Tools - Stuff to get computer literate non-programmers in control of their Tesla

cURL - Many operating systems come with this handle utility already installed. The REST API can be called using various "curl" commands from your computers command shell (terminal).

Example curl command to login to Tesla and get a cookie with your authentication token. Replace "USERNAME" and "PASSWORD" with your actual Tesla website login and password.

Code:
curl -c cookies.txt -d "user_session[email]=USERNAME&user_session[password]=PASSWORD" https://portal.vn.teslamotors.com/login
Example curl command to get the vehicle information (including "id" needed for all other commands)

Code:
curl -b cookies.txt https://portal.vn.teslamotors.com/vehicles
Example curl command to start charging (replace "ID" with the three to five digit "id" of your car, as returned by the previous command)

Code:
curl -b cookies.txt https://portal.vn.teslamotors.com/vehicles/ID/command/charge_start
Example curl command to check the current charge state

Code:
curl -b cookies.txt https://portal.vn.teslamotors.com/vehicles/ID/command/charge_state
Example curl command to get data from the Streaming API. Replace "USERNAME" with your actual Tesla website login (as in the REST API). Replace TOKEN with the first of the two tokens returned in the output of the previous curl command for vehicle information. Replace LONG_VEHICLE_ID with the 10 digit "vehicle_id" also returned with the vehicle information (note that this is different than the "id" used in the REST API calls).

Code:
curl -u USERNAME:TOKEN https://streaming.vn.teslamotors.com/stream/LONG_VEHICLE_ID/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range,heading
Streaming data will not return for up to 2 minutes if the car is not moving. When moving the data will return at 4 updates per second (i.e. samples every 250 milliseconds) and stop after two minutes. When the two minute long poll returns, you will need to poll again for another two minutes of streaming data. This is a normal "HTTP long polling" method of streaming data.

The first field returned is a timestamp in the form of number of seconds since the birthdate of Unix (midnight, January 1st, 1970).

Tokens rollover or expire every 15 minutes (at exactly the top of the hour :00, or 15, 30, and 45 past the hour). Since there are two tokens, the first one in the list will last for up to 30 minutes.

If no tokens are present, you will need to wake up the car using the REST API call for wake_up in order to get new tokens.Replace "ID" with the three digit "id" of your car as in the previous REST commands.

Code:
curl -b cookies.txt https://portal.vn.teslamotors.com/vehicles/ID/command/wake_up

Fiddler - The free web debugging proxy for any browser, system or platform
 
Last edited by ACDriveMotor
  • Informative
Reactions: gpetti

jsgoecke

Member
Nov 20, 2015
11
4
Half Moon Bay, CA
Is this definition still valid, or is there a new spec? I am trying to use the Ruby lib, my own tests, etc, and with a valid email/password I get 500 backs from the Tesla servers.
 

Ulmo

Active Member
Jan 19, 2016
4,328
4,427
Vienna Woods, Aptos, California
I had a shower thought this morning. It makes us realize that we are asking for things more modern than are really available. Here it is:

Shower thought:

Elon Musk seems more modern than he is; he brings early 1980s solutions to a 1950s world. Grow up Elon!

People like Elon Musk & Donald Trump seem modern when they really aren’t as modern as they seem. Most of the world is stuck in the 1950’s, so when Trump comes along many decades more modern, or Musk comes with his early 1980’s solutions to everything, they seem really modern in comparison.

For instance, where is PGP, Bitcoin in Tesla, USA commerce? Why isn’t the API key in MyTesla a public-private key pair for each user with settable permissions? We've had that since late 1980's. Even the concept of users with permissions has been around since before the 1970's.
 

AmIDigital

New Member
Aug 21, 2017
3
2
Tuscaloosa Alabama
Is it possible to develop for Tesla when I don't have a car? I'd like to build the attached HVAC scheduler now but will not receiving my model 3 for a year.

bqXKn30
 

fallen888

Participant
Jul 27, 2016
808
571
Newtown, PA
I wrote a Windows service a little while ago that reminds me to plug in if I forgot to plug in while at home after 9pm. You can configure it to your preferences.

fallen888/my-tesla

There's an Android app code in there too, but it's half baked and I abandoned the Xamarin version (in favor of pure Java version that I'm writing), so don't bother with that project. But the Windows service works - I've been using it for over a year.
 
  • Like
Reactions: bahree

bahree

Member
Jul 9, 2018
86
44
Seattle
That's interesting.. I never heard of JuiceBox before. Pretty cool, but I wouldn't shell out $500+ for it. Maybe $100.. I'm cheap. :D
I understand. My rationale was that its similar in price to the Tesla chargers, and one isn't locked in with them and allows for more flexiblity.
 

zephyrus

New Member
Jun 16, 2020
1
0
carson city
Tried the first curl command:
Failed to connect to portal.vn.teslamotors.com port 443: Timed out
Is there an update to this old post? I'm looking for the ability to be notified when charger is not connected but I don't want to give up my login credentials to someone else's app
 

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top