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.
Sorry seems I wrote in a haste. It's unable to log in at all. Using visible tesla it logs in and tells me I'm a lucky bastard to have two, but doesn't proceed beyond the car selection. With the streamer or teslacmd it doesn't even log in... And I'd be happy to test stuff :)

are you familiar with Linux and Perl?
If so, i've got a script I use that gathers telemetry from a Banana Pi (Raspberry Pi but with SATA interface) into mongodb.
Its a ~250 line perl script that gathers vehicle_state, drive_state, climate_state, charge_state as well as streaming telemetry and as far as i know it will gather data for multiple cars on the same account.

no point me sharing it with you unless you can actually install/run the code though, there ain't no GUI on it. :)
 
I run a datacenter for CERN calculations :) I've also written a few lines into the linux kernel etc ;) I think I can manage it though I've never liked perl I have to admit due to its write once style ;)

tree/code is at lincolntdale/tesla_telemetry · GitHub

run it once, it will create a config file and exit (default is /root/tesla/tesla_poller.cfg).
edit that file and where it says INSERT_USERNAME_HERE and INSERT_PASSWORD_HERE put your teslamotors.com email/password there.
then run it a second time and it'll stream various outputs to you.

this is my perl rewrite of hjespers/teslams · GitHub / Tesla Model S JSON API—by apiary.io / and a few other sources in this forum, as i didn't want to run this in the cloud elsewhere and wanted it on a raspberry pi so as to be energy frugal at home.

i have more code than this - e.g. heatmap of energy, speed etc over google maps, long-term storage of telemetry etc, but need to scrub some of that before posting.
this could/should get you started.

i've been running this in a loop for pretty much a month now, no downsides yet. tesla not rate-limiting my data as far as i can tell, so i think its being a good web citizen.
 
Type of arg 1 to keys must be hash (not private variable) at ./poller.pl line 180, near "$json) "
Execution of ./poller.pl aborted due to compilation errors.

Took a bunch of additional libraries that I had to add to get it to execute without dependency issues, but won't run due to this error. The offending code:

foreach my $k (keys $json) {
printf "\t%s: %s\n",$k,$json->{$k};
}

The perl I use: perl-5.10.1-130.el6_4.x86_64
 
Anyone have the format of the new API version of set_charge_limit? I am POSTing that command (via WinJS.xhr) and getting a 200 return but the vehicle charge limit is not changing.

Request: {
"url":"https://owner-api.teslamotors.com/api/1/vehicles/{id}/command/set_charge_limit/",
"responseType":"json",
"type":"POST","
data":{"percent":70},"
headers":{"Authorization":"Bearer {token}"}
}

Response: "{\"response\":{\"reason\":\"\",\"result\":true}}"

Other commands and data_requests seem to work fine.
 
Anyone have the format of the new API version of set_charge_limit? I am POSTing that command (via WinJS.xhr) and getting a 200 return but the vehicle charge limit is not changing.

Request: {
"url":"https://owner-api.teslamotors.com/api/1/vehicles/{id}/command/set_charge_limit/",
"responseType":"json",
"type":"POST","
data":{"percent":70},"
headers":{"Authorization":"Bearer {token}"}
}

Response: "{\"response\":{\"reason\":\"\",\"result\":true}}"

Other commands and data_requests seem to work fine.

Try 70 as a string rather than as an integer (i.e. "data": { "percent": "70" } ).