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.
Yes, tesla mobile app uses same endpoint. I'm just running a process of elimination...

I can't really offer much advice past change your password, and hope that does somthing...

Ok, completely my dumb and everything in the world is fine. I walked away from debugging, watched the finale of Stranger Things 2 and then came back to the code. I then noticed that the response code was 200 and previously the response was 200 OK, my code was checking the response incorrectly before proceeding - feel like an idiot :$
 
Playing around with the official APIs, specifically the GET /api/1/diagnostics endpoint and thought the return was interesting:

Code:
{"response":{"eligible":false}}

I have a Model S 60D, just curious if this could relate to the uncorking that is sometimes possible on older models? I'd be curious to see anyone else's data returned from this endpoint.
 
Playing around with the official APIs, specifically the GET /api/1/diagnostics endpoint and thought the return was interesting:

Code:
{"response":{"eligible":false}}

I have a Model S 60D, just curious if this could relate to the uncorking that is sometimes possible on older models? I'd be curious to see anyone else's data returned from this endpoint.

I tried it and got a 500 error. How does it know what vehicle to provide data back without sending in the vehicle_id?
 
Any interest in using our browser-based Tesla Management Portal? CLI version already available here.

DN9AvN_VwAAQxgL.jpg
 
  • Like
Reactions: scottf200
Not from Tesla at all. It is a portal to manage your Tesla that is independent from Tesla Motors. Sorry for the confusion. That is spelled out in part of the image that was clipped.

Code:
Copyright © 2013-2017, Ward Mundy & Associates LLC and Blackrock Digital LLC with MIT License
Tesla is a trademark of Tesla, Inc. This site is neither affiliated with nor endorsed by Tesla Motors.
 
Last edited:
I tried it and got a 500 error. How does it know what vehicle to provide data back without sending in the vehicle_id?
I notice I get a 500 error some times as well. Try making a call to get all of your vehicle data (GET /api/1/vehicles/{vehicle_id}/data) immediately before doing the diagnostic call as this is what the official app does. Also make sure your authorization (bearer) token is in the headers like with any other request.

Any more information on that endpoint? Get/post/Payload/uri etc.?
There are 2 end points - a GET and a POST. No clue what the payload is for the POST, but the GET has nothing fancy just maybe the prerequisite that you access your vehicle data right before making the call (read above):

Code:
GET https://owner-api.teslamotors.com/api/1/diagnostics HTTP/1.1
content-type: application/json; charset=utf-8
user-agent: Mozilla/5.0 (Linux; Android 5.0.1; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36
x-tesla-user-agent: TeslaApp/3.2.1-334/1ec459a1f/android/5.0.1
authorization: Bearer [redacted]
Host: owner-api.teslamotors.com
Connection: Keep-Alive
Accept-Encoding: gzip

Code:
  "DIAGNOSTICS_ENTITLEMENTS": {
    "TYPE": "GET",
    "URI": "api/1/diagnostics",
    "AUTH": true
  },
  "SEND_DIAGNOSTICS": {
    "TYPE": "POST",
    "URI": "api/1/diagnostics",
    "AUTH": true
  },
 
Last edited:
  • Helpful
Reactions: scottf200
I am using wardmundy's php files and can read charge_state, climate_state and data.
I can change temperatures with set_hvac_temp. but I can't set charge limits and I can't start or stop charging!

working (for changing temps):
$params = array('driver_temp' => $driver_temp, 'passenger_temp' => $passenger_temp);
$response =queryTeslaAPI($TOKEN, "api/1/vehicles/".$ID."/command/set_temps",true,$params);

NOT working:
$response =queryTeslaAPI($TOKEN, "api/1/vehicles/".$ID."/command/charge_stop",true);

Anyone has a hint for me what possibly is going wrong?
 
The init.php file does use POST instead of GET when needed. (indicated by ",true" in the line above)
I discovered it still needed the $params at the end, AND have an empty parameter defined in it, even when a parameter is not necessary for the particular command.

so, WORKING:
$params = array (' ' => " ");
$response =queryTeslaAPI($TOKEN, "api/1/vehicles/".$ID."/command/charge_stop",true,$params);

I am happy now!
 
  • Helpful
Reactions: rabar10
As of this monday, I've observed some changes to the data the APIs are serving to newer firmwares (2017.46 3387a54 for example).

The vehicle config end point has 2 new boolean fields - plg and can_actuate_trunks. I suspect the latter is a hint of what's to come, the ability to open/close the trunks remotely. No clue what the "plg" could stand for.

The vehicle state endpoint has had its overlapping vehicle config data removed, so fields like car_type, dark_rims, exterior_color, rhd, sun_roof_installed, etc. have been removed from the vehicle state data but are still served from the vehicle config endpoint.
 
As of this monday, I've observed some changes to the data the APIs are serving to newer firmwares (2017.46 3387a54 for example).

The vehicle config end point has 2 new boolean fields - plg and can_actuate_trunks. I suspect the latter is a hint of what's to come, the ability to open/close the trunks remotely. No clue what the "plg" could stand for.

The vehicle state endpoint has had its overlapping vehicle config data removed, so fields like car_type, dark_rims, exterior_color, rhd, sun_roof_installed, etc. have been removed from the vehicle state data but are still served from the vehicle config endpoint.
Plg = Power Lift Gate
 
Anyone do any work on the Tesla API in Lua? I have been able to do some rudimentary stuff, like getting the list of vehicles, but I am having issues parsing the JSON info as that seems a little trickier in Lua vs Python, and I have no idea what I am doing in Lua. You seem to get a table with the JSON data which I am able to put in a sink, and I can get at that data by parsing the string variable but it would be nice to turn it into proper JSON.

Lua is popular with Home Automation systems and this is the reason that I am interested - writing a Tesla API driver for my HA system.
 
Anyone do any work on the Tesla API in Lua? I have been able to do some rudimentary stuff, like getting the list of vehicles, but I am having issues parsing the JSON info as that seems a little trickier in Lua vs Python, and I have no idea what I am doing in Lua. You seem to get a table with the JSON data which I am able to put in a sink, and I can get at that data by parsing the string variable but it would be nice to turn it into proper JSON.

Lua is popular with Home Automation systems and this is the reason that I am interested - writing a Tesla API driver for my HA system.
I have no experience in Lua, but I imagine a library to deserialise the JSON should exist