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

Model S REST API

This site may earn commission on affiliate links.
New APIs returning all 404s?

Good news, everyone!

I finally updated the API docs for the new oAuth API and some of the new endpoints: Tesla Model S JSON API · Apiary

If anyone has any ideas about the upcoming_calendar_entries, notification_preferences, and vehicle_subscriptions endpoints (or any that I've missed), I can get those added too.

Most of these endpoints are returning 404 for me now....For instance:

https://owner-api.teslamotors.com/api/1/vehicles/[my vehicle id]/data_request/wake_up

I was wondering if anyone else is able to hit these endpoints and get data?
 
I'd be interested in hearing if anyone is having any luck with the new API locations....I can get a vehicle list, but any kind of data request, such as:

curl -H "Authorization: Bearer [my bearer token]" -H "Content-Type: application/json" -i https://owner-api.teslamotors.com/api/1/vehicles/[my vehicle id]/data_request/charge_state

Just results in a 404....



Everything seems to work for me... Beware totally lazy Python below.

#!/usr/bin/python
import requests
oauthit = {"grant_type" : "password",
"client_id" : "YOURCLIENTIDHERE",
"client_secret" : "YOURCLIENTSECRETHERE",
"email" : "YOUREMAILHERE",
"password" : "YOURPASSWORDHERE" }
print oauthit


r = requests.post("https://owner-api.teslamotors.com/oauth/token", data=oauthit)
print r.text





Take the results from above and plug the bearer bits into the head below(all caps YOURBEARERAUTHHERE)


I bet you can figure out how to get your own vehicle ID (all caps in the below)





#!/usr/bin/python
import requests
print "hello"
url = "https://owner-api.teslamotors.com/api/1/vehicles"
head = {"Authorization": "Bearer YOURBEARERAUTHHERE"}
r = requests.get(url,headers=head)
print r.text
url = "https://owner-api.teslamotors.com/api/1/vehicles/VEHICLEID/data_request/charge_state"
r = requests.get(url,headers=head)
print r.text
url = "https://owner-api.teslamotors.com/api/1/vehicles/VEHICLEID/data_request/vehicle_state"
r = requests.get(url,headers=head)
print r.text
url = "https://owner-api.teslamotors.com/api/1/vehicles/VEHICLEID/data_request/climate_state"
r = requests.get(url,headers=head)
print r.text
 
Wow, crazy, thanks for the python code....As it turns out, I was using Postman (a Chrome Plugin) to execute the request for vehicle lists. For some reason, when doing so the ID of the vehicle that comes back in the payload is completely different then what is returned from python or curl, for instance (which explains my 404).

It looks like a bug with the little utility I was using, not the API. Thanks so much man, this was driving me nutty!
 
Yeah, that vehicle ID drove me nuts too. In php you have to set a special "BIGINT" parameter in order to retrieve it properly.

Same in Javascript. You can retrieve it just fine as a string but once you parse the string as JSON it rounds off the ID to a smaller number of significant digits unless you use a special BIGINT parser like sidorares/json-bigint · GitHub.

In the teslams libraries I convert ID and VEHICLE_ID into strings so nobody else has to re-implement this silly logic.
 
I noticed today that the temperature data returns seat heater state info for three rows of seats. I'm pretty sure that the jump seats in the trunk of the Model S aren't heated so this must be a placeholder for the Model X. It seems likely that this would allow for remotely controlling or at least visualization on the mobile apps.

Code:
{ inside_temp: 47,
  outside_temp: 26,
  driver_temp_setting: 19.8,
  passenger_temp_setting: 19.8,
  is_auto_conditioning_on: true,
  is_front_defroster_on: 0,
  is_rear_defroster_on: false,
  fan_status: 10,
  seat_heater_left: 0,
  seat_heater_right: 0,
  seat_heater_rear_left: 0,
  seat_heater_rear_right: 0,
  seat_heater_rear_center: 0,
  seat_heater_rear_right_back: 0,
  seat_heater_rear_left_back: 0,
  smart_preconditioning: false }
 
Everything seems to work for me... Beware totally lazy Python below.

#!/usr/bin/python
import requests
oauthit = {"grant_type" : "password",
"client_id" : "YOURCLIENTIDHERE",
"client_secret" : "YOURCLIENTSECRETHERE",
"email" : "YOUREMAILHERE",
"password" : "YOURPASSWORDHERE" }
print oauthit
Sorry, as this is probably a really dumb question, but where do I get a client_id and a client_secret? I don't remember setting anything like that up before - just my email and password.
 
Sorry, as this is probably a really dumb question, but where do I get a client_id and a client_secret? I don't remember setting anything like that up before - just my email and password.

Tesla does not currently give these out so you have no choice today other than to extract Tesla's credentials from one of the official mobile apps. Extracting credentials is not something you want to be discussing in a public forum unless it's a hacker forum.
 
After some updates, command/wake_up POST isn't working for me but all the (non-streaming) data_request GETs are. Any tips on what I might be messing up? Thanks.

System.Net.WebException: The remote server returned an error: (401) Unauthorized.
 
Last edited: