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.
Hello, I am attempting to access the stream data as indicated by a previous post

curl --user USERNAME:TOKEN https://streaming.vn.teslamotors.co...est_heading,est_lat,est_lng,power,shift_state

This works just fine in a Terminal window (Mac OS X), but my question is how would I handle the authorization --user USERNAME:TOKEN in a WebSocket call. I have tried in the socket header but that did not work.

I am able to get all non stream api working including login, etc. through traditional get/post but it is the stream data that has me searching the web and confused. I am using Swift.

Thank you

Why use the streaming API to get stuff like car position? That can be achieved with the owner API. Read more here.
 
I tried to make use of the option codes, but there were ultimately too many and felt unreliable moving forward. I use the VIN to decode the information I need avoiding option codes as much as possible, but there are some places I still need to parse it, such as body paint color.

I don't see how this helps me. I've decoded my VIN and all it tells me is that I have a dual motor car. I also need to know battery capacity and if its Performance. Here is my VIN: 5YJSB7E29GF1*****

I need to tell which battery the user has apart from Dual Motor. I need to be able to pin point the exact model. Its no use not being able to tell if the VIN is a 60D or 70D or 75D or 90D.
 
My script detected 4 new fields in the API today:

1) vehicle_state->time stamp
ex: timestamp: 1484278017699

2) charge_state->time stamp
ex: timestamp: 1484278018398

3) charge_state->charge_port_led_color
ex: charge_port_led_color: Blue

4) drive_state->power
ex: power: 0

I'm most excited about the charge_state time stamp and the drive state power. Those could be interesting.

Any idea what these timestamps are associated with? They are not associated with beginning or end of a charging session because I get a different number every time I send a query. Seems like the timestamps are associated withe response (which isn't very useful).
 
  • Like
Reactions: SG57
Hey guys, I'm trying to get the drive_state, but my GET call is failing. First of all, yes, I'm successfully logging in, and GETting vehicles list (with one vehicle). I'm using that one vehicle's vehicle_id to GET the drive state, but I keep getting a 404 not found response.

My GET url is: https://owner-api.teslamotors.com/api/1/vehicles/[vehicle_id_omitted]/data_request/drive_state

And the response I get back is:

HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 25 Jan 2017 03:35:10 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 60
Connection: keep-alive
Status: 404 Not Found
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-cache
X-Request-Id: 9c3c5e7d-b3fe-42de-a266-9d964bdc35cf
X-Runtime: 0.045617

{"response":null,"error":"not_found","error_description":""}

What am I missing here? Thanks in advance.
 
Hey Everyone, trying to access the API and I'm getting this error when running it.

when run ./token.php PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /php-api-tesla/token.php:9 Stack trace: #0 {main} thrown in /php-api-tesla/token.php on line 9

Does anyone know what I may be missing? Appreciate it!
 
Hey Everyone, trying to access the API and I'm getting this error when running it.

when run ./token.php PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /php-api-tesla/token.php:9 Stack trace: #0 {main} thrown in /php-api-tesla/token.php on line 9

Does anyone know what I may be missing? Appreciate it!

This would not be enough information to debug. You would need to provide your code that generated the error. This just says your code is broken. You may also want to read the following... ensure you have the right library installed, etc...


Call to undefined function curl_init().?
 
Sure, I appreciate it and with some more trial and error I believe we got in and got the access that we needed.

We are able to see the vehicle ID and know that things are working but to a point. Any commands related to "charge port door", "flash lights", etc all are return NULL. Do you know why this could be? Seems only 2 commands work: token.php and vehicle.php,
Example:
the rest return null and init.php gives errors:
yakov@yakov-Satellite-C675D:/php-api-tesla$ ./init.php
./init.php: line 1: ?php: No such file or directory
./init.php: line 3: syntax error near unexpected token `0'
./init.php: line 3: `//error_reporting(0);'

I am working with someone as I am not the technical part of this equation. I know he has tried python and php.. Thoughts, comments or suggestions?

Thanks!!