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.
Would you expect to be any less accurate than the latitude/longitude? The original question was about fetching elevation from lat/long, IIRC.
Definitely less accurate. The topic is covered in the link I provided.

You were saying the streaming API provided elevation data. I'd guess that elevation data came from GPS, but GPS elevation calculations have a comparatively large margin of error. You'll get better information by using the lat/long to look up the elevation data from some reference source, as you had suggested.
 
Definitely less accurate. The topic is covered in the link I provided.

You were saying the streaming API provided elevation data. I'd guess that elevation data came from GPS, but GPS elevation calculations have a comparatively large margin of error. You'll get better information by using the lat/long to look up the elevation data from some reference source, as you had suggested.
Ah, ok. Good to know. Lame but good to know.
 
Did I miss it or is there no REST command for setting (or raising/lowering) the charge rate at the current location? Technically you could "throttle down" but starting and stopping every few seconds but that seems like a bad idea.

What I'm looking for is a way to set the charge rate to, say, 6 amps like you can via the in-car UI.
 
I'm trying to access the streaming service via c#, and am having an authorization issue.
Here is a snippet of my code:

HttpWebRequest request = HttpWebRequest.CreateHttp("https://streaming.vn.teslamotors.com/stream/" + vehicle_id + "/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range");
request.Method = "GET";
request.Credentials = new NetworkCredential(this.email, token);

When I run this, I get an http error, but if I pass the same values to curl it works. What is the correct way to pass the authorization in c#?
Thanks!
 
I'm trying to access the streaming service via c#, and am having an authorization issue.
Here is a snippet of my code:

HttpWebRequest request = HttpWebRequest.CreateHttp("https://streaming.vn.teslamotors.com/stream/" + vehicle_id + "/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range");
request.Method = "GET";
request.Credentials = new NetworkCredential(this.email, token);

When I run this, I get an http error, but if I pass the same values to curl it works. What is the correct way to pass the authorization in c#?
Thanks!
I'll try to remember to check and reply when I get home. I'm pretty sure I'm not using ".Credentials" anywhere in my source.
 
I'm trying to access the streaming service via c#, and am having an authorization issue.
Here is a snippet of my code:

HttpWebRequest request = HttpWebRequest.CreateHttp("https://streaming.vn.teslamotors.com/stream/" + vehicle_id + "/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range");
request.Method = "GET";
request.Credentials = new NetworkCredential(this.email, token);

When I run this, I get an http error, but if I pass the same values to curl it works. What is the correct way to pass the authorization in c#?
Thanks!


Are you sure you are using the same token in C# and your curl script? When the token expires you will get a HTTP 401: Unauthorized response.
Tokens expire every 15 minutes from the top of the hour (i.e. Noon, 12:15, 12:30, 12:45, etc.)
 
Definitely used the same token, even refreshed. I still get a 401 error, I guess I just need to know what is the way to set the email/token information in C#.

- - - Updated - - -

I figured it out. I was calling ReadToEnd instead of ReadLine.
 
Definitely used the same token, even refreshed. I still get a 401 error, I guess I just need to know what is the way to set the email/token information in C#.
Here's what I use:
Code:
req.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(strBasicAuthInfo));
where strBasicAuthInfo is
Code:
strEmail + ":" + _token
 
Thanks. I've tried setting the Authorization header, but then I just get an out of memory exception trying to read the response.

What platform are you running this on? I had to workaround an issue on windowsphone and the streaming api when the car is not moving (no data + not providing a content-length) which results in an out of memory exception you can't catch. The non-phone http stacks don't have the bug.

- - - Updated - - -

- - - Updated - - -

Does anyone have a snapshot of charge_state data while supercharging? I had a report from someone that they data looked wrong from my app while supercharging... There is a supercharger somewhat near me now, but 2 hours driving to get there and back to collect this is a little out of the way :)
 
Does anyone have a snapshot of charge_state data while supercharging? I had a report from someone that they data looked wrong from my app while supercharging... There is a supercharger somewhat near me now, but 2 hours driving to get there and back to collect this is a little out of the way :)

This is roughly 17 minutes after a peak of 288 mi/hr (90 kW) charge rate.

20130711_054836.dat said:
charging_state=Charging
charge_limit_soc=90
charge_limit_soc_std=90
charge_limit_soc_min=50
charge_limit_soc_max=100
charge_to_max_range=false
battery_heater_on=false
not_enough_power_to_heat=false
max_range_charge_counter=0
fast_charger_present=true
battery_range=138.69
est_battery_range=159.64
ideal_battery_range=159.62
battery_level=59
battery_current=137.0
charge_starting_range=null
charge_starting_soc=null
charger_voltage=377
charger_pilot_current=0
charger_actual_current=0
charger_power=-52
time_to_full_charge=0.52
charge_rate=257.6
charge_port_door_open=true
scheduled_charging_start_time=null
scheduled_charging_pending=false
user_charge_enable_request=null
charge_enable_request=true

In case it's useful, here are the min/max across my entire DAT set:
battery_current=-357.0
battery_current=178.9
charge_rate=291.2
charger_voltage=400
 
Last edited: