Tesla API Access


Thanks for letting me know. I didn’t notice until you posted. I lost my vehicle Id during the Tesla/Aws failure and it wasn’t scheduled to pull the new token for another couple days. I executed the piston and it ran flawlessly. Thanks again for letting me know and for putting the piston together.


I’m not entirely sure if I’m doing something wrong with the first piston. It assigns the string @accessToken and datetime @tokenExpiration global variables, but does not assign the string @vehicleID.

Perhaps I’ve overlooked something?

I’ve entered my email and password in ONLY the two areas provided as per instructions, but when I TEST the piston, I get an error. :frowning:


From your log, it looks like you’re using an out-of-date version of the piston—which is my fault, as I should have updated the top post after some recent changes. Try the piston included in this post here.

Thank you for the reminder to update the post.



Thanks for the reply.
One thing I was thinking, I use TESLAFI.COM which generates its own token for car access. Does your piston generating its own token interfere with TeslaFI’s token? The reason I’m asking is I literally just got an email from them saying:

" TeslaFi.com was denied access using your token with Tesla.com and logging has been turned off.
This may be because your token has expired or you changed your password on Tesla.com. You can generate a new token in settings->account->Tesla API Token."


That worked! :slight_smile:


Yes. If you generate a token independently of TeslaFi you must provide it to them so that they can authenticate with the API.


So what would you recommend? Use Teslafi token in WebCoRE, or use WebCoRE token in Teslafi?


That’s really a toss-up depending on how you use either service. Whichever one is more critical is the one I would use to generate the token.


Oh oh… something broke. :frowning:
Is there a way to fix this?

This is after half a dozen ON/OFF’s to understand how this works.



The URL is malformed. Not enough info there to explain why.


Sorry for the late reply… it was something as simple as a typo on a variable. Your code is working great and I’m learning how to execute the various API commands.

I’m not sure if you will know this, but how often can we fetch updates from Tesla’s API? Can I do it every minute, or 2 or perhaps every 5? Will this cause issues with Tesla’s servers and come back at me somehow that you’re aware of?

This is what I’ve done so far with using SharpTools dashboards.


I do not know the specifics for Tesla, but general courtesy is to only query APIs as much as necessary.
(since every query from every user has an impact on the entire system)


I’ve never encountered any kind of limit, and I assure you I’ve hit the API pretty hard at times while testing pistons, etc., but I agree with @WCmore that it should be done only as necessary. I’ve seen times when limits on other APIs were imposed, or access was terminated or made a ‘premium’ feature because users were abusing their access.


Would once every 5 minutes (for WebCoRE purposes) when parked at home keep me under their radar?


Probably, although I would advise against waking your car up that often unless Sentry Mode is already active and keeping it awake.


I would definitely add a condition that info refreshes would only occur when the car is plugged in at home when it’s parked inside my garage.


Battery drain is just one aspect of it. Waking and restarting the car’s computer more often than necessary just seems unwise. But that’s me, and it’s probably not my place to comment anyway since I don’t know what you’re trying to accomplish.


Hmmm… something to consider and re-think my end goal.


Hi @bthrock, I just got a email from Teslafi stating that the authentication flow changed and Tesla is no longer allowing the v2 tokens to be refreshed when they expire, and to generate a new v3 token. (Their words :slight_smile:).

I’m not sure what the difference between the v2 and v3 tokens but I figure I reach out and ask whether the WebCore script still works with the new Tesla authentication model. Looking around it looks like Tesla has deprecated the /oauth/token endpoint in favor of using auth.tesla.com.

My piston executed two days ago and is set to expire early March so I’m not hitting any problems but I figure I throw out the question to see if anyone has uncovered anything.



I’m aware of this. I will have to update the piston that maintains a current token, but have not done so as yet.

Some more information here in case anybody want to get ahead of me on this.