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.
I'd like to test with a curl, could you please send the right command ?
I'm trying to use Teslapy but I can't manage to make it to work, even with a container... Really strange
Es^pecially as my phone app is working perfectly

The authentication doesn't boil down to just one curl command. Sorry if I gave that impression. What I did was use my web browser to authenticate, and then used the web browser's network debugging tool to capture the auth code. But it looks like now they have a check in there against the user-agent header to prevent using a web browser.

To use curl, you would have to process the HTML returned by the first URL, fill out the form, and submit it with another curl command. I just took the auth token I generated once, generated a bearer token, and then I just keep renewing the bearer token. So I can help from that point, on, but I don't have a good way to do the first part of the authentication.
 
Does anyone have the API commands for changing charging current yet? That's apparently released on iOS now (subject to car being on 2012.36+)

very interested as well

From this:


I see:

Code:
  "CHARGING_AMPS": {
    "TYPE": "POST",
    "URI": "api/1/vehicles/{vehicle_id}/command/set_charging_amps",
    "AUTH": true
  },

I don't exactly how to use it, but I presume its usage is consistent with other API commands.
 
From this:


I see:

Code:
  "CHARGING_AMPS": {
    "TYPE": "POST",
    "URI": "api/1/vehicles/{vehicle_id}/command/set_charging_amps",
    "AUTH": true
  },

I don't exactly how to use it, but I presume its usage is consistent with other API commands.

Use command "CHARGING_AMPS" with parameter charging_amps=value (where value = between 5-32 (EU)).
 
  • Like
Reactions: markb1
Re chaging_amps, we've been chatting about it over here Adjust Tesla charge rate from mobile app, API & PW2 to allow use of excess solar but probably best to centralise API-based discussions on this thread..
Use command "CHARGING_AMPS" with parameter charging_amps=value (where value = between 5-32 (EU)).
tried this too, still getting a 404 in postman... most likely bcos the car's not on 2021.36 yet.. if anyone's on .36 and can verify this endpoint and parameter I'd be very interested. At least it gives us a head start coding for it before the car's FW drops.

I switched to this library and it hasn't been working for me for roughly 2 months now.
me too, i just tried it, didnt work. I think Tesla updated their login page so it doesn't take the "credentials" form post field automatically anymore and has to be key'ed in, which of course doesnt work since it's a HttpClient that runs on backend and doesnt present a window. maybe Tom will update the code later. For now I'm just generating oauth2.0 tokens via Postman and using it till it expires - then repeat. Hopefully this gets fixed soon.
 
me too, i just tried it, didnt work. I think Tesla updated their login page so it doesn't take the "credentials" form post field automatically anymore and has to be key'ed in, which of course doesnt work since it's a HttpClient that runs on backend and doesnt present a window. maybe Tom will update the code later. For now I'm just generating oauth2.0 tokens via Postman and using it till it expires - then repeat. Hopefully this gets fixed soon.

From the README:

Probably the most reliable way of using the library is to integrate a WebView into your application and have it show Tesla's login UI. This approach should be resilient to certain changes on Tesla's side, such as when they randomly decide to include (and later remove) a CAPTCHA on the login page. Since Tesla incorporated a CAPTCHA on their login page, it is no longer possible to authenticate using your own UI.

The Test.WPF project demonstrates a complete login and refresh flow. The sample only runs on Windows, but the library itself is cross platform (e.g. works on Xamarin).

Have you tried Test.WPF? As I said earlier, that's what I used to test the library, and it did work. I don't think the library will get updated to accommodate every change that Tesla makes to the login page. You'll have to use a webview, or similar. Fortunately, once you gotten a renewal token, you can keep the session alive forever and never repeat the login step.
 
Re chaging_amps, we've been chatting about it over here Adjust Tesla charge rate from mobile app, API & PW2 to allow use of excess solar but probably best to centralise API-based discussions on this thread..

tried this too, still getting a 404 in postman... most likely bcos the car's not on 2021.36 yet.. if anyone's on .36 and can verify this endpoint and parameter I'd be very interested. At least it gives us a head start coding for it before the car's FW drops.
Yes, your car need to be on FW 2021.36 or newer for it to work. I'm on this version, and here it works fine after I found the right parameter to send with the command.
Can also see the changes in the Tesla mobile app "on the fly" when the car is charging and you adjust the Amp setting via your app.
 
  • Like
Reactions: lonertic
:( I don't have visual studio installed, and I would prefer to not install it...
Not possible to compile a small executable with the demo in it pleasssse ???

I only need a token to setup my connection into openhab, it's a bit overkill to install vStudio for that no ?
 
:( I don't have visual studio installed, and I would prefer to not install it...
Not possible to compile a small executable with the demo in it pleasssse ???

I only need a token to setup my connection into openhab, it's a bit overkill to install vStudio for that no ?

Personally, I wouldn't trust a binary from a random stranger on the internet... but I can probably find a way to send it to you, if you really want.
 
Personally, I wouldn't trust a binary from a random stranger on the internet... but I can probably find a way to send it to you, if you really want.
Yeah, I know you're right, and even if you are really nice with me, I must confess I would have some difficulties to use it...
I don't understand what's goin on with this... I'll finally install VStudio, even if I wanted to avoid to do this... :)
 
I was developing a local streaming application and using the vehicle_data endpoint to get some data. During some testing, I received a "not found" error from the endpoint.

I discovered, after some investigation, that the id_s of my vehicle changed. I found it odd because I've had the same id_s since I took ownership over 18 months ago. Anyone else see their id_s change?

Joe
 
Just remember to install Visual Studio Community Edition, not Visual Studio Code.
Hey Markb1,

Could you please provide me some help in using the test.wpf ? I'm not able to run it properly, VStudio always say that I'm missing libraries and so on... I guess I need to put VStudio in a specific "development mode" (webapp for instance), but I can't find the correct way to do so...
Thanks for your help already...
 
Hey Markb1,

Could you please provide me some help in using the test.wpf ? I'm not able to run it properly, VStudio always say that I'm missing libraries and so on... I guess I need to put VStudio in a specific "development mode" (webapp for instance), but I can't find the correct way to do so...
Thanks for your help already...

Hmm.. what libraries is it complaining about? Be sure to check ".NET desktop development" under the workloads tab in the Visual Studio installer. (Since you've already installed it, you can run the installer again from your start menu and click the modify button to add or remove features.) I think that should get you everything you need for this app.

Also, be sure to set Test.WPF as the startup project. (It should be bold in the Solution Explorer. If not, right click on it, and select "Set as Startup Project". Then it's just a matter of starting it from the Debug menu (either Start or Start Without Debugging). That will build it and run it.