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

API Testing

This site may earn commission on affiliate links.
I've been looking at the Tesla APIs and am thinking about trying something out (mostly for my own benefit, but hopefully for others if it's useful).

I'll try and get it working for myself first but wanted to find out if there was anybody brave enough to sign in with their credentials. People who live nearby might be best so they can confirm I'm not just some dodgy person on the internet (I live in Bishops Stortford, UK).

Send me a DM if you're interested.
 
I don't think its entirely clear what you are asking people TBH. I assume you are going to create an app or a web page to issue the api commands? so you are not asking people to send their credentials to you just to enter them but of course if you were malicious they could be harvested from wherever people are entering them into? is that a fair summary?
 
Yes - exactly that same risk you carry with other apps. This is why I was hoping for somebody local so we could meet. Once I've made more progress I can share what the app does and the trade-off might be worth it but at this stage, I'm just hoping to build a local network to help with testing. If not I shall have to try randomly befriending Tesla drivers (I've seen a few nearby!) :)
 
I'm afraid I am not local and am not going to volunteer but I have done extensive "playing" with the api's so if you need any help my inbox is always open :)
I built a data logging service that polls my car every few minutes and stores all the data returned ( but does not prevent it from sleeping) and an event scheduler that lets me schedule charging and heating etc. Its basically a very cut down version of What Telsafi does but just for my own use.
good luck
 
  • Like
Reactions: LukeUK
Appreciated! I have the early stages of an app - once it does one of the key things I'm looking for (putting my windows up once I park the car) I'll make sure to share!

Love to know what you use to identify when the car can be polled. Currently, I have a list of "lively" events like driving and charging.
 
It’s great to add some genuinely useful automation. I trigger my Node Red API calls with Siri/Apple Shortcuts.

A few ideas for those with the know-how:

Get the car ready’ and ‘Warm up the car’ do the same thing. Check the temp and decide whether to preheat/demist or just a/c on, heat the seats etc.

open the charge port’ as per command

Trigger some charging scripts to pull the Octopus Agile rates and charge at lowest rates (instead of OHME/EV.energy app). ‘Below rate’ or ‘charge by’.

11:00am check the met office observations. If it’s over 20 degrees and sunny, wake up the car so that it thinks about cabin overheat.

Poll the cars location under certain conditions and ‘warm up the house’ when I enter a geofence (Hive Heating).

No sharing of password/credentials- albeit this won’t be for the majority of people. If in doubt stick with TeslaFi.
 
..and if the Ring doorbell detects motion overnight, turn on Sentry for 20 mins.



I just check if /api/1/vehicles/{I’d} returns a state of “online” if I don’t necessarily want to wake the car.
The problem is if you are doing data logging and always poll when it is online then it will never go to sleep. so you have to check for indicators that it is going to go to sleep and stop polling for a while to allow it. it's a bit of a black art.
but as norfolk mustard said typical indicators that the car ought to be trying to sleep are:
not being driven
no user present
sentry mode off
climate off

I also use locked but this would not be appropriate for everyone

if all of these are true then if you stop polling for 15 to 20 minutes the car should go to sleep.

The problem is if someone gets in and drives during those 20 minutes when you pause polling then you can miss the start of the journey as Teslafi users will tell you.
 
  • Like
Reactions: NewbieT
Polling is an art form and getting wrong is going to keep the car awake and eat battery. Different developers do different things including setting sleep windows or in the case of Teslamate they say they use the streaming API (which is hard to find any documentation) and only when they see a message do they poll the car.

I'm all for personal endeavour but there's loads of stuff on github where people have done lots of stuff without needing peoples credentials and presumably you haven't got your own car to test with?

The biggest issue I have is the weakness in Tesla security and lack of 2 factor authentication is owners have no idea if their car details or token have been leaked and therefore used by others. Doesn't matter how good you think the 3rd party is the weakness is you not knowing - Teslafi have introduced 2FA but its still not addressing the elephant in the room which is Tesla. As such I'd only ever recommend locally hosted solutions such as Teslamate on a raspberry Pi. Thats not to put you off, thats suggesting whatever you're developing make it all executable on the device and not via a server otherwise you're just another of the 100 homebrew bedroom developed penny applications that nobody in their right mind that understands the risks should touch.
 
  • Like
Reactions: NewbieT
Why not use the streaming API like TeslaMate that doesn’t poll?
because I don't think that is a thing. There is only one set of API's for the car and all the services use them.
If you want to get data form the car you have to call it. The more often you want it the more you have to call it.
There is a API that does not go to the car which returns the last state that the car reported to the Tesla servers. Online, Asleep, etc but that is about all it does tell you. if they added a state of "Trying to sleep" that would solve everyone's issues. does not seem likely though.
 
Last edited:
Polling is an art form and getting wrong is going to keep the car awake and eat battery. Different developers do different things including setting sleep windows or in the case of Teslamate they say they use the streaming API (which is hard to find any documentation) and only when they see a message do they poll the car.

I'm all for personal endeavour but there's loads of stuff on github where people have done lots of stuff without needing peoples credentials and presumably you haven't got your own car to test with?

The biggest issue I have is the weakness in Tesla security and lack of 2 factor authentication is owners have no idea if their car details or token have been leaked and therefore used by others. Doesn't matter how good you think the 3rd party is the weakness is you not knowing - Teslafi have introduced 2FA but its still not addressing the elephant in the room which is Tesla. As such I'd only ever recommend locally hosted solutions such as Teslamate on a raspberry Pi. Thats not to put you off, thats suggesting whatever you're developing make it all executable on the device and not via a server otherwise you're just another of the 100 homebrew bedroom developed penny applications that nobody in their right mind that understands the risks should touch.
The problem with that is that you are then dependant on your own internet connection and hardware, power cuts etc. plus the risk of actually losing all the data you already harvested if your storage fails.
To get around that I do use my own setup but I run it on Amazon Web services so its virtually bulletproof from a reliability point of view so I get the best of both worlds. It's also basically free at the level I use it which is nice. Obviously I am dependant on AWS security but TBH the whole world runs on there including half our govt so If they get significantly compromised my API key being in the wild will be the least of anyone's worries.
 
TeslaMate says "Falling asleep since X" so it seems to know (or guess) a different state from "Online" or "Asleep".

I've seen the car "falling asleep" for several hours when it's been hot, when the Cabin Overheat protection is toggling on and off, so TeslaMate doesn't seem to just guess when the car should be asleep, it knows, and without actually keeping it awake by checking.
 
TeslaMate says "Falling asleep since X" so it seems to know (or guess) a different state from "Online" or "Asleep".

I've seen the car "falling asleep" for several hours when it's been hot, when the Cabin Overheat protection is toggling on and off, so TeslaMate doesn't seem to just guess when the car should be asleep, it knows, and without actually keeping it awake by checking.
I'm afraid its just doing what the rest of us are. Checking all of the markers that indicate the car is not being used and ought to be trying to sleep and then assuming that is the case and setting a status for itself of Falling asleep since the time it made that determination
 
I'm afraid its just doing what the rest of us are. Checking all of the markers that indicate the car is not being used and ought to be trying to sleep and then assuming that is the case and setting a status for itself of Falling asleep since the time it made that determination

Thats not whats been reported. There is an API that doesn't seem to be so public that updates the map when you're driving which is a stream you subscribe to rather than a polled system - as such you monitor don't poll (my understanding is a little hazy and i may use the wrong term but I understand the difference between polling something and push notifications).

You doning a private hosted environment of say teslamate is better than Teslafi. They use AWS as well and spout lots of stuff, but at the end of the day you don't know if they get breached and I imagine lots of people are interested in hacking them. In your AWs environment, people wouldn't even know it was there.
 
Thats not whats been reported. There is an API that doesn't seem to be so public that updates the map when you're driving which is a stream you subscribe to rather than a polled system - as such you monitor don't poll (my understanding is a little hazy and i may use the wrong term but I understand the difference between polling something and push notifications).

You doning a private hosted environment of say teslamate is better than Teslafi. They use AWS as well and spout lots of stuff, but at the end of the day you don't know if they get breached and I imagine lots of people are interested in hacking them. In your AWs environment, people wouldn't even know it was there.
Well they didn't know until I just told everyone :)
fair enough on the streaming. I was not aware of that but I am not sure how it helps you determine the state of your car which is what was being discussed at that point. it all it does is deliver map and navigation data from the server?
 
Well they didn't know until I just told everyone :)
fair enough on the streaming. I was not aware of that but I am not sure how it helps you determine the state of your car which is what was being discussed at that point. it all it does is deliver map and navigation data from the server?

From what I've read it monitors the streaming and starts polling when it sees a stream. It can't rely on that entirely but they can be more aggresive with their sleep code as the car moving would ake up the polling. DOn't know for sure but the guy that wrote it seem convinvincing enough and I believe part developed Teslamate - of course like all internet stuff it could be rubbish