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.
Hey all, is there a definitive wake up process established? I've read many variations thought we could come up with a trusted method.

My idea (can't test as my model S doesn't arrive til September):
  1. Poll */vehicles*
  2. Check vehicle *state*
    1. If *online*, done.
    2. If not *online*, continue.
  3. Send *wake_up*
  4. Repeat 1 & 2 with delay until timeout
I saw reports stating *wake_up* isn't reliable, that *vehicle_state* is more reliable, etc. etc.

We have a lot of unofficial API documentations out there, but it seems we're lacking a resource for the real world usage of them. Another good example would be the streaming API, something even the unofficial documentations are lacking (please prove me wrong!)
 
Hi All,
New to this thread. I'm trying to make my own Tesla app for windows in Visual Basic. I'm using the code from the API docs and it returns an access token. However, passing that token into the header give me a 404. Is the API playing up or is there a special way to pass the token to the server? I'm happy to give my code to a VB expert for critique.
 
Hi All,
New to this thread. I'm trying to make my own Tesla app for windows in Visual Basic. I'm using the code from the API docs and it returns an access token. However, passing that token into the header give me a 404. Is the API playing up or is there a special way to pass the token to the server? I'm happy to give my code to a VB expert for critique.

What's the code for your header look like?
 
Hi All,

Author of the EV Watch and Tesla Waze Website here. Seeing all the difficulties with the API, I'm experimenting with a new project to provide an alternate Tesla API endpoint. The main objectives are to:
  • Avoid having to hit your personal Telsa account and potentially trigger any rate limits or suffer any side effects
  • Test with different configurations without having to actually own them (e.g. Multiple Teslas or alternate models like the Model X).
  • Potentially have more insight into error conditions outside of what the stock REST api provides. (e.g. "Your token is wrong" ,"your vehicle id is wrong", "value makes no sense", etc..)
  • Ability to emulate external state changes like temperature/SOC/location/speed/doors/driving changes.



Tesla API Simulator


Disclaimer: This is at *alpha* development stage. Especially the autopark/web sockets stuff which I haven't been able to verify; my model S is pre-autopilot and the current implementation is just an approximation based off of various threads.
 
  • Like
Reactions: Prefect
Hi All,

Author of the EV Watch and Tesla Waze Website here. Seeing all the difficulties with the API, I'm experimenting with a new project to provide an alternate Tesla API endpoint. The main objectives are to:
  • Avoid having to hit your personal Telsa account and potentially trigger any rate limits or suffer any side effects
  • Test with different configurations without having to actually own them (e.g. Multiple Teslas or alternate models like the Model X).
  • Potentially have more insight into error conditions outside of what the stock REST api provides. (e.g. "Your token is wrong" ,"your vehicle id is wrong", "value makes no sense", etc..)
  • Ability to emulate external state changes like temperature/SOC/location/speed/doors/driving changes.



Tesla API Simulator


Disclaimer: This is at *alpha* development stage. Especially the autopark/web sockets stuff which I haven't been able to verify; my model S is pre-autopilot and the current implementation is just an approximation based off of various threads.

As someone with a single S who had to create a custom XML and put it on an Azure endpoint to test how my app would handle more than a single vehicle, let me say this: "Where were you 2 months ago!!"

J/K, this should come in really helpful, specially your new summon streaming examples which I haven't fixed on my app yet.

PS: if you want to do some testing on the Summon API against a car with Summon shoot me a PM and we can test it with my car, I have a long driveway.

Thanks.
 
Hi All,

Author of the EV Watch and Tesla Waze Website here. Seeing all the difficulties with the API, I'm experimenting with a new project to provide an alternate Tesla API endpoint. The main objectives are to:
  • Avoid having to hit your personal Telsa account and potentially trigger any rate limits or suffer any side effects
  • Test with different configurations without having to actually own them (e.g. Multiple Teslas or alternate models like the Model X).
  • Potentially have more insight into error conditions outside of what the stock REST api provides. (e.g. "Your token is wrong" ,"your vehicle id is wrong", "value makes no sense", etc..)
  • Ability to emulate external state changes like temperature/SOC/location/speed/doors/driving changes.



Tesla API Simulator


Disclaimer: This is at *alpha* development stage. Especially the autopark/web sockets stuff which I haven't been able to verify; my model S is pre-autopilot and the current implementation is just an approximation based off of various threads.

Do the auth parameters really have to be placed in the query string like that? Attempting to auth is failing on my side due to posting a JSON body instead of in the query string. Does the official API support both?
 
And might I suggest for the 2 vehicle account to actually have 2 distinct vehicles? As is, they have the same VIN numbers which broke some items of mine that required that to be unique.

Otherwise, looks solid! Love the persistence, saves a lot of time instead of having to manually update my mock server with desired results of a command.
 
HankLloydRight: Did you get the commands working?
Yeah, everything is working now. The problem was I was in the middle of debugging my code when the API went down that morning, so I couldn't tell if it was my code or the API. I assumed the API was working and kept trying to figure out why my code didn't work. Very frustrating when my code was totally fine all along!
 
Do the auth parameters really have to be placed in the query string like that? Attempting to auth is failing on my side due to posting a JSON body instead of in the query string. Does the official API support both?
It should work although I only tested on the regular api commands and not the auth.

And might I suggest for the 2 vehicle account to actually have 2 distinct vehicles? As is, they have the same VIN numbers which broke some items of mine that required that to be unique.

Otherwise, looks solid! Love the persistence, saves a lot of time instead of having to manually update my mock server with desired results of a command.

Ah, thought I modified the second record slightly but guess I missed some pieces. Eventually I plan to expose the functions to directly modify the underlying model.

I'm unfortunately going to be afk for the next couple weeks. Will fix these items when I get back!

Thanks for the notes!
 
Hi All,

Author of the EV Watch and Tesla Waze Website here. Seeing all the difficulties with the API, I'm experimenting with a new project to provide an alternate Tesla API endpoint. The main objectives are to:
  • Avoid having to hit your personal Telsa account and potentially trigger any rate limits or suffer any side effects
  • Test with different configurations without having to actually own them (e.g. Multiple Teslas or alternate models like the Model X).
  • Potentially have more insight into error conditions outside of what the stock REST api provides. (e.g. "Your token is wrong" ,"your vehicle id is wrong", "value makes no sense", etc..)
  • Ability to emulate external state changes like temperature/SOC/location/speed/doors/driving changes.



Tesla API Simulator


Disclaimer: This is at *alpha* development stage. Especially the autopark/web sockets stuff which I haven't been able to verify; my model S is pre-autopilot and the current implementation is just an approximation based off of various threads.

Hi,
Your emulator is awesome. I got an access token from it, but when I try this call: https://tesla.flawedmodel.com/api/1/vehicles I get a 404.
Interesting. I'm sure I'm missing something my code must be the problem.
 
Hi,
Your emulator is awesome. I got an access token from it, but when I try this call: https://tesla.flawedmodel.com/api/1/vehicles I get a 404.
Interesting. I'm sure I'm missing something my code must be the problem.
Thanks! Looking at your previous post, it looks like your auth header may not be correct. It should look like:

"Authorization: Bearer tokenXYZ"

Where tokenXYZ should be replaced by whatever you got from the oauth/token call
 
Thanks! Looking at your previous post, it looks like your auth header may not be correct. It should look like:

"Authorization: Bearer tokenXYZ"

Where tokenXYZ should be replaced by whatever you got from the oauth/token call
Hi,
My visual basic code now looks like:
request.Headers.Add("Authorization: Bearer 123123123123123123123") (random numbers are the token)

Same problem. Any help would be appreciated, I know I'm missing something.