Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • We just completed a significant update, but we still have some fixes and adjustments to make, so please bear with us for the time being. Cheers!

Model S REST API

mianesva

Member
Oct 2, 2018
6
15
NH
Thank you for replying :)

I use this: https://owner-api.teslamotors.com/api/1/vehicles/<vehicleid>/command/actuate_trunk?which_trunk=rear

All other commands work.


Your request likely looks like:

POST /api/1/vehicles/zzzzzzz/command/actuate_trunk?which_trunk=rear HTTP/1.1
User-Agent: yyyyy
Authorization: Bearer xxxxx
Host: owner-api.teslamotors.com
Connection: close
Content-Length: 0


with your values for x,y,z....

I duplicated your current result of:

{"response":{"reason":"invalid_value","result":false}}


Instead of passing the commend as parameter on the url just pass them as value in the body. Note the additional Content-Type header and its value to indicate the type of data you are passing in the body for the POST request

POST /api/1/vehicles/zzzzzz/command/actuate_trunk HTTP/1.1
User-Agent: yyyyy
Authorization: Bearer xxxxxx
Content-Type: application/json
Host: owner-api.teslamotors.com
Connection: close
Content-Length: 22

{"which_trunk":"rear"}


Which yields a valid response:

{"response":{"reason":"","result":true}}
 
  • Helpful
Reactions: scottf200

nasatech

Supporting Member
May 19, 2016
273
191
Oslo
Instead of passing the commend as parameter on the url just pass them as value in the body. Note the additional Content-Type header and its value to indicate the type of data you are passing in the body for the POST request

Perfect! Got it working. Thanks :)
 

ACDriveMotor

Member
Aug 11, 2013
890
24
Seattle, WA
Does the API support changing the charging start time? I can't find it, but it seems like a pretty fundamental need. If the answer is "no", then are all the apps that support changing the start time just manually starting the charge at the new time from the app/server end? Sounds crazy to me!
Tesla Control lets you schedule start and stop times. It’s done with background tasks.
 

lonertic

Member
Feb 2, 2017
49
21
Sydney
I can find the start/stop charging commands (no details about what the httpbody payload should be though?)... however, is there such a command that could set the charging current remotely? I haven't seen one in the official app but I'm wondering if an API for it exists (or if someone managed to sniff one out)?
 

Dazboj

Member
May 9, 2017
86
25
UK
I can find the start/stop charging commands (no details about what the httpbody payload should be though?)... however, is there such a command that could set the charging current remotely? I haven't seen one in the official app but I'm wondering if an API for it exists (or if someone managed to sniff one out)?

Unfortunately not. This is a holy grail I have been waiting for (And tweeting Elon).
If the API allowed us to set the charge rate, I could utilise much more of my solar export by keeping the charge rate the same as solar excess.
 
  • Love
Reactions: lonertic

lonertic

Member
Feb 2, 2017
49
21
Sydney
Unfortunately not. This is a holy grail I have been waiting for (And tweeting Elon).
If the API allowed us to set the charge rate, I could utilise much more of my solar export by keeping the charge rate the same as solar excess.
EXACTLY the reason why I asked for it too :) Tweet him again, I'd imagine we're not the only ones thinking about this... Since my solar inverter can't work in island mode, and I can't send any predetermined amount of power towards the car first before exporting excess, having the car "pull" a corresponding amperage out of the inverter in line with solar output seems to make a lot of sense!

I'm guessing you already tried obvious stuff like command/set_charge_current (as opposed to set_charge_limit) just to see if the API actually exists right? (i just tested it now, got a 400 bad request).. that makes me think, i wonder what other hidden APIs there are.. possible able to just guess a bunch i think
 

dpskipper

Developer
Aug 4, 2016
187
44
Australia
EXACTLY the reason why I asked for it too :) Tweet him again, I'd imagine we're not the only ones thinking about this... Since my solar inverter can't work in island mode, and I can't send any predetermined amount of power towards the car first before exporting excess, having the car "pull" a corresponding amperage out of the inverter in line with solar output seems to make a lot of sense!

I'm guessing you already tried obvious stuff like command/set_charge_current (as opposed to set_charge_limit) just to see if the API actually exists right? (i just tested it now, got a 400 bad request).. that makes me think, i wonder what other hidden APIs there are.. possible able to just guess a bunch i think
Mate it doesn't exist
 

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
Unfortunately not. This is a holy grail I have been waiting for (And tweeting Elon).
If the API allowed us to set the charge rate, I could utilise much more of my solar export by keeping the charge rate the same as solar excess.

There's a different way to achieve this, by using the load sharing protocol of the Tesla Wall Connector. (This requires wiring something to the wall connector.) There's a thread here:

New Wall Connector load sharing protocol

And source code here:

cdragon/TWCManager
 

lonertic

Member
Feb 2, 2017
49
21
Sydney
There's a different way to achieve this, by using the load sharing protocol of the Tesla Wall Connector. (This requires wiring something to the wall connector.) There's a thread here:
Nice! But unfortunately my car is 2015, so is my HPWC... so I can only assume it's the "older" model with older firmware/hardware that can't run that... and it wouldn't be as precise as the car controlling draw either, because HPWC selector is still in stepped amps, whereas car is single digit amp changes... really wish an API was available! :( What about canbus message within the car? anyone?
 

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
Nice! But unfortunately my car is 2015, so is my HPWC... so I can only assume it's the "older" model with older firmware/hardware that can't run that... and it wouldn't be as precise as the car controlling draw either, because HPWC selector is still in stepped amps, whereas car is single digit amp changes... really wish an API was available! :( What about canbus message within the car? anyone?

It requires a second generation wall connector, but I believe it will work with any Model S/X/3.
 

dpskipper

Developer
Aug 4, 2016
187
44
Australia
Nice! But unfortunately my car is 2015, so is my HPWC... so I can only assume it's the "older" model with older firmware/hardware that can't run that... and it wouldn't be as precise as the car controlling draw either, because HPWC selector is still in stepped amps, whereas car is single digit amp changes... really wish an API was available! :( What about canbus message within the car? anyone?
That's doable, as the car is the one that talks to EVSE and requests the current
 

insaneoctane

Active Member
Apr 6, 2016
3,369
5,183
Southern California
Don't know if anyone here cares, but the newest firmware 46.x changed the timestamp format for charging start time again. It's back to long-UNIX style UTC, no longer readable with the "T" in the middle. Re-broke some of my scripts after the update. Just had to go back to before Nov. 2 to see what I had changed so that I could undo it.
 
  • Informative
  • Funny
Reactions: SG57 and nasatech

SG57

Former Vendor
Jul 24, 2016
400
570
Spokane, WA
So I'm digging into the latest app version and like the new nearby charging station APIs.

Endpoint: api/1/vehicles/{vehicle_id}/nearby_charging_sites
Method: GET
* Bearer Token auth header required

Response Sample:

Code:
{
   "response":{
      "congestion_sync_time_utc_secs":1545270496,
      "destination_charging":[
         {
            "location":{
               "lat":60.480312,
               "long":22.327951
            },
            "name":"Unique Home",
            "type":"destination",
            "distance_miles":1.645089
         },
         {
            "location":{
               "lat":60.460714,
               "long":22.290152
            },
            "name":"Holiday Club Caribia",
            "type":"destination",
            "distance_miles":2.673828
         },
         {
            "location":{
               "lat":60.4554,
               "long":21.9516
            },
            "name":"Kultaranta Resort",
            "type":"destination",
            "distance_miles":14.195284
         },
         {
            "location":{
               "lat":60.163116,
               "long":22.732845
            },
            "name":"K-Supermarket Kompass",
            "type":"destination",
            "distance_miles":24.419037
         }
      ],
      "superchargers":[
         {
            "location":{
               "lat":60.442961,
               "long":22.605621
            },
            "name":"Paimio, Finland - Tammisilta",
            "type":"supercharger",
            "distance_miles":8.271776,
            "available_stalls":8,
            "total_stalls":8,
            "site_closed":false
         },
         {
            "location":{
               "lat":61.181106,
               "long":23.885075
            },
            "name":"Akaa, Finland - Toijala",
            "type":"supercharger",
            "distance_miles":71.047409,
            "available_stalls":8,
            "total_stalls":8,
            "site_closed":false
         }
      ],
      "timestamp":1545271308686
   }
}

-

And on that note, I'm excited my Model S got the latest software update earlier today so I'm gonna try to guess the new seat heater / steering wheel heater control endpoint seeing as the mobile app update with support for it hasn't been released yet. :eek:
 

ckoval7

Mild One
Sep 19, 2018
662
599
Maryland
And on that note, I'm excited my Model S got the latest software update earlier today so I'm gonna try to guess the new seat heater / steering wheel heater control endpoint seeing as the mobile app update with support for it hasn't been released yet.
I just came here to ask if anyone found it yet! Hopefully we see the app update soon!
 
  • Like
Reactions: SG57

SG57

Former Vendor
Jul 24, 2016
400
570
Spokane, WA
@ACDriveMotor , haven't found it yet. I've tried 50+ different combinations of "set", "heater", "seat", "level", "limit", "heating", "element", etc. If you get a 400 status code it's wrong, if you get anything else then we're in business.

There's a chance Tesla doesn't enable the endpoint until the 3.8.0 app release as well.
 
Last edited:

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