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

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
Is there any way to check if the car is awake without actually waking up the car? Or do all of the functions just fail if the car is asleep and you don't send the wake call first?

When you query the vehicle list, it will tell you whether the car is awake without waking the car. The other commands will wake the car.
 
  • Informative
Reactions: scottf200

luckyj

Member
Dec 8, 2016
412
495
Northern Virginia, USA
So I saw some of the comments in the MS forum about the app having issues. Seems like it started working again, at least for some folks.

What I'm wondering about is some of the REST interface, because I still get 404 errors on attempting wake up and vehicle_data pulls...
 

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
So I saw some of the comments in the MS forum about the app having issues. Seems like it started working again, at least for some folks.

What I'm wondering about is some of the REST interface, because I still get 404 errors on attempting wake up and vehicle_data pulls...

I was getting errors (mostly 502, bad gateway) from 4:22pm to 7:13pm PDT yesterday. Not sure what would cause a 404.
 

darth_vad3r

Well-Known Sith
May 6, 2019
1,574
1,119
Canada
So I saw some of the comments in the MS forum about the app having issues. Seems like it started working again, at least for some folks.

What I'm wondering about is some of the REST interface, because I still get 404 errors on attempting wake up and vehicle_data pulls...
I was getting errors (mostly 502, bad gateway) from 4:22pm to 7:13pm PDT yesterday. Not sure what would cause a 404.

Yesterday afternoon/evening (Pacific) I was getting errors like "our servers are waiting for a supercharger spot" (not an error technically, served back an HTML page instead of a JSON response :))

After that, once it was working today, I noticed my id and id_s changed (totally different numbers from before now, and not the same as each other, last digit differs).

Once in a while I see random errors (like 401 or 404) that seem to just go away after a few retries of the exact same request.
 

darth_vad3r

Well-Known Sith
May 6, 2019
1,574
1,119
Canada
Is this affecting sites like telsafi? They all use this API don't they?

Yes, they all use the same API... I don't know if anything changed to affect them. Seems like yesterday there was some kind of outage for a while.

I don't know if the id changing was a widespread or total fleet-wide thing, or localized just to me, or ... what ??? :)

The id changing shouldn't affect any well-designed app or service, I would think anyways. For us hacking about, if anyone's hard-coded their vehicle's 'id' or 'id_s' it would affect us until we update the hard-coded values.
 
  • Like
Reactions: KWReid

darth_vad3r

Well-Known Sith
May 6, 2019
1,574
1,119
Canada
Just got a "techincal issues" notification, anyone else?

"If you are having problems viewing your products, please log out and back into the app as our systems recover from techincal issues."
So ya, their servers were waiting for a supercharger spot for a while it seems.
 

Roadrunner13

Member
Oct 16, 2013
392
144
Montreal
...
I don't know if the id changing was a widespread or total fleet-wide thing, or localized just to me, or ... what ??? :)

The id changing shouldn't affect any well-designed app or service, I would think anyways. For us hacking about, if anyone's hard-coded their vehicle's 'id' or 'id_s' it would affect us until we update the hard-coded values.

It changed IDs for a couple of folks with different loggers from what I've seen (including me)...so you were not unique (sorry!) and clearly Tesla doesn't consider these IDs as unique identifiers either! lol
 

John Rucker

Member
Sep 4, 2019
34
8
Illinois
Yeah, so it was my vehicle id that changed, thus the 404. I wasn't pulling the id dynamically...

Got the new id and it's working fine now.


Yep my car's ID changed as well yesterday (2019 Model X). I now lookup the Tesla Car ID based on my VIN every time my node app starts. That should address future changes.

I want to say thanks to @KWReid for the shift_state = Null (car wants to sleep). I implemented that yesterday and it appears to be working well.

My polling logic:
  • If car is asleep poll ever two minutes and check if on-line by reading the /api/1/vehicles endpoint.
  • When car is awake poll every minute and read the charge status from the /api/1/vehicles/mycarid/data_request/charge_state endpoint
    • Also in the same poll cycle check and see if the shift_state = null (indicating the car would like to sleep) at /api/1/vehicles.
    • If it is null change to a 15 minute poll cycle to let the car sleep.
I will be testing this over the next few days. From looking at the Tesla app on my phone it looks like it is updating every five or so seconds. I'm basing this on the little spinning icon that appears in the header right next to my Wi-Fi signal strength icon on my iPhone when I have the Tesla app open. So my once a minute polling shouldn't be a big load I wouldn't think. I can back it off it will not cause a problem. But from what I have been reading on this forum my polling logic seems to be inline with others. Any concerns?

Just as an FYI; My Node.JS app monitors the charging progress and sends it to a physical gauge that hangs on the wall. The gauge displays Battery Charge, Charge Rate, and Time to Full Charge.
 
  • Like
Reactions: KWReid

KWReid

Member
Oct 16, 2018
54
27
Vancouver, BC
I want to say thanks to @KWReid for the shift_state = Null (car wants to sleep). I implemented that yesterday and it appears to be working well.

You're welcome. But I found out about it through a google result at TeslaFi. I just verified the back-off strategy and shared my success story here. ;)

Just as an FYI; My Node.JS app monitors the charging progress and sends it to a physical gauge that hangs on the wall. The gauge displays Battery Charge, Charge Rate, and Time to Full Charge.

OK. That's pretty cool. Is it some kind of built in API on the gauge, or something more custom?
 

John Rucker

Member
Sep 4, 2019
34
8
Illinois
OK. That's pretty cool. Is it some kind of built in API on the gauge, or something more custom?
It is an open source platform for displaying IOT telemetry on a physical gauge. It is a project I have been working on for about two years now. Up to this point I have used it to create physical gauges for displaying river levels (Mississippi River, and Illinois River, etc) and their NOAA forecast levels. I have also used it to create a gauge that shows my home's solar panel power production. Last month I bought my wife a Model X for our anniversary and started poking around with the API. I have the first version of a Tesla Charge Gauge on the wall in my office. I have a long ways to go but your little trick has helped me simplify my polling process. Check out WallGauge.com if you're curious about how the gauge works.
 
  • Like
Reactions: darth_vad3r

darth_vad3r

Well-Known Sith
May 6, 2019
1,574
1,119
Canada
It is an open source platform for displaying IOT telemetry on a physical gauge. It is a project I have been working on for about two years now. Up to this point I have used it to create physical gauges for displaying river levels (Mississippi River, and Illinois River, etc) and their NOAA forecast levels. I have also used it to create a gauge that shows my home's solar panel power production. Last month I bought my wife a Model X for our anniversary and started poking around with the API. I have the first version of a Tesla Charge Gauge on the wall in my office. I have a long ways to go but your little trick has helped me simplify my polling process. Check out WallGauge.com if you're curious about how the gauge works.

Cool. Should have some that can mount on the dash for engine power, battery level, etc :)
 

HankLloydRight

No Roads
Jan 18, 2014
12,821
10,834
Connecticut
Can anyone shed some light on why both:
https://owner-api.teslamotors.com/api/1/vehicles/{id}/vehicle_data
or
https://owner-api.teslamotors.com/api/1/vehicles/{id}/data

are both returning a 404?

I can query https://owner-api.teslamotors.com/api/1/vehicles just fine.

Yes, I'm sending the proper string Authorization: Bearer 2879684cfd496577c14833acba8ac7e980734f35e56c40a27cd0e505095c5189

thanks.


Nevermind. It's the new difference between {id} and {id_s}. All the calls now require {id_s} which as noted above is -2 from {id}. Strange.
 
Last edited:

KWReid

Member
Oct 16, 2018
54
27
Vancouver, BC
Nevermind. It's the new difference between {id} and {id_s}. All the calls now require {id_s} which as noted above is -2 from {id}. Strange

That's not what I'm seeing. I get the "id" property and use that for requesting details. My "id" response in the vehicle status JSON is the same as id_s. The prior isn't bound by quotes, and the latter is bounded by quotes.

There was a change recently that broke my API calls because I was lazy and just used a hardcoded ID which was changed recently. Now I use the "id" property for my follow up details call rather than assuming it's always the same.
 

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