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 see
"is_front_defroster_on":null

I don't think I've seen
"is_front_defroster_on":3

But I don't think I've tried it with the front defroster on. My car is currently in service, but when I get it back I check with different settings. I'm still hoping for a way to control the rear seat heat from the API. Having to ask the driver to adjust your seat heat is silly.

I've seen that return null, true, false, and '3' As near as I can tell 'true' means on, and all other values mean false - if you look at 3rd party Tesla apps, they often screw up and show the front defroster as 'on' because they interpret '3' as non-zero/non-null and think it means "on". Nope, "3" is sometimes returned for off for some reason.
 
Well, this sucks: Just checked the API after upgrading to 8.1 and saw that the "battery_current" API field of charge_state has been removed. This was quite useful for tracking vehicle state; I guess that's the risk of using an undocumented and unsupported API.
Can you give an example output of your 8.1 fields so those of us without it can compare with our 8.0 logs and see how they differ.
 
Here you go - full output from the /data endpoint, this should include all the data structures available to the API.

charge_state has lost battery_current and charge_port_led_color. In exchange, I got a couple of properties related to autopark in vehicle_state: autopark_style, homelink_nearby, last_autopark_error. I'm not sure if the "vehicle_config" section was already there prior to 8.1

IDs/tokens/location/display_name have been changed

Code:
{
    "response": {
        "id": 12345678901234567,
        "user_id": 123456,
        "vehicle_id": 1234567890,
        "vin": "5YJSA7E25HF170000",
        "display_name": "MyModelSName",
        "option_codes": "MDLS,REEU,ADPX2,ADX4,ADX6,ADX7,ADX8,AF02,APF2,APH2,APPB,AU01,BCMB,BP00,BR00,BS00,BTX4,CDM0,CF00,CH04,PPSB,CW02,DCF0,DRLH,DSH7,DV4W,FG02,FR04,HP00,IDBA,IX01,LP01,ME02,MI01,PF00,PI01,PK00,PS01,PSPRX4,PSPX4,PX00,QTVB,RFP2,SC01,SP01,SR01,SU01,TM00,TP03,TR00,UTAW,WTAS,WXW2,WXW3,X001,X003,X007,X011,X014,X021,X025,X027,X028,X031,X037,X039,X044,YFFC,COAT",
        "color": null,
        "tokens": ["xxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxx"],
        "state": "online",
        "in_service": false,
        "id_s": "12345678901234567",
        "remote_start_enabled": true,
        "calendar_enabled": true,
        "notifications_enabled": true,
        "backseat_token": null,
        "backseat_token_updated_at": null,
        "drive_state": {
            "shift_state": null,
            "speed": null,
            "power": 0,
            "latitude": 47.012345,
            "longitude": 15.012345,
            "heading": 105,
            "gps_as_of": 1490880319,
            "timestamp": 1490880319938
        },
        "gui_settings": {
            "gui_distance_units": "km/hr",
            "gui_temperature_units": "C",
            "gui_charge_rate_units": "kW",
            "gui_24_hour_time": true,
            "gui_range_display": "Ideal",
            "timestamp": 1490880319924
        },
        "climate_state": {
            "inside_temp": null,
            "outside_temp": null,
            "driver_temp_setting": 20.5,
            "passenger_temp_setting": 20.5,
            "left_temp_direction": null,
            "right_temp_direction": null,
            "is_auto_conditioning_on": null,
            "is_front_defroster_on": null,
            "is_rear_defroster_on": false,
            "fan_status": 0,
            "is_climate_on": false,
            "min_avail_temp": 15.0,
            "max_avail_temp": 28.0,
            "seat_heater_left": 0,
            "seat_heater_right": 0,
            "seat_heater_rear_left": 0,
            "seat_heater_rear_right": 0,
            "seat_heater_rear_center": 0,
            "seat_heater_rear_right_back": 0,
            "seat_heater_rear_left_back": 0,
            "smart_preconditioning": false,
            "timestamp": 1490880319940
        },
        "charge_state": {
            "charging_state": "Disconnected",
            "charge_limit_soc": 86,
            "charge_limit_soc_std": 90,
            "charge_limit_soc_min": 50,
            "charge_limit_soc_max": 100,
            "charge_to_max_range": false,
            "battery_heater_on": null,
            "not_enough_power_to_heat": false,
            "max_range_charge_counter": 0,
            "fast_charger_present": false,
            "fast_charger_type": "<invalid>",
            "battery_range": 207.67,
            "est_battery_range": 170.24,
            "ideal_battery_range": 166.58,
            "battery_level": 59,
            "usable_battery_level": 59,
            "charge_energy_added": 43.87,
            "charge_miles_added_rated": 181.5,
            "charge_miles_added_ideal": 146.0,
            "charger_voltage": 0,
            "charger_pilot_current": 24,
            "charger_actual_current": 0,
            "charger_power": 0,
            "time_to_full_charge": 0.0,
            "trip_charging": false,
            "charge_rate": 0.0,
            "charge_port_door_open": false,
            "scheduled_charging_start_time": null,
            "scheduled_charging_pending": false,
            "user_charge_enable_request": null,
            "charge_enable_request": true,
            "charger_phases": null,
            "charge_port_latch": "Blocking",
            "charge_current_request": 24,
            "charge_current_request_max": 24,
            "managed_charging_active": false,
            "managed_charging_user_canceled": false,
            "managed_charging_start_time": null,
            "motorized_charge_port": true,
            "eu_vehicle": true,
            "timestamp": 1490880319939
        },
        "vehicle_state": {
            "api_version": 3,
            "autopark_state": "unavailable",
            "autopark_state_v2": "ready",
            "autopark_style": "dead_man",
            "calendar_supported": true,
            "car_type": "s2",
            "car_version": "17.11.3",
            "center_display_state": 0,
            "dark_rims": false,
            "df": 0,
            "dr": 0,
            "exterior_color": "SignatureBlue",
            "ft": 0,
            "has_spoiler": false,
            "homelink_nearby": false,
            "last_autopark_error": "no_error",
            "locked": true,
            "notifications_supported": true,
            "odometer": 2819.188237,
            "parsed_calendar_supported": true,
            "perf_config": "P1",
            "pf": 0,
            "pr": 0,
            "rear_seat_heaters": 1,
            "rear_seat_type": 0,
            "remote_start": false,
            "remote_start_supported": true,
            "rhd": false,
            "roof_color": "None",
            "rt": 0,
            "seat_type": 2,
            "spoiler_type": "None",
            "sun_roof_installed": 2,
            "sun_roof_percent_open": 0,
            "sun_roof_state": "unknown",
            "third_row_seats": "None",
            "timestamp": 1490880319936,
            "valet_mode": false,
            "valet_pin_needed": true,
            "vehicle_name": "MyModelSName",
            "wheel_type": "AeroTurbine19"
        },
        "vehicle_config": {
            "car_special_type": "base",
            "car_type": "s2",
            "eu_vehicle": true,
            "exterior_color": "SignatureBlue",
            "has_ludicrous_mode": false,
            "motorized_charge_port": true,
            "perf_config": "P1",
            "rear_seat_heaters": 1,
            "rear_seat_type": 0,
            "rhd": false,
            "roof_color": "None",
            "seat_type": 2,
            "spoiler_type": "None",
            "sun_roof_installed": 2,
            "third_row_seats": "None",
            "timestamp": 1490880319938,
            "trim_badging": "90d",
            "wheel_type": "AeroTurbine19"
        }
    }
}
 
Vehicle config is recent, but it seems to contain a lot of the same information in the previous sections so it seems redundant. I see some new things in it, though:
"trim_badging": "90d"
"has_ludicrous_mode": false,

Is your sun roof the glass one that doesn't move? I'm trying to figure out what the value of 2 means for sun_roof_installed.

Looks like they also got rid of charge_port_led_color, which was also a redundant field since it could be extrapolated from the other fields.

Sucks that they removed battery_current. That was a useful field.
 
Ok, somewhat off topic question, but you developers have probably dealt with this tax question before:
As a developer who writes apps for Tesla, have you tried to write-off a portion of the cost of the car as business expense?
IRS rules look at the car as a "car" and if you don't drive the car for business purposes, don't allow any write-off. In the case of a car like Tesla, the situation a different because how much you drive the car for business is not relevant (it's really like a computer which happens to also have wheels).

Very interested to know what you guys (developers) have done.
 
There is an entry in the charge_state that indicates whether car is a European car or not ("eu_vehicle").
European cars have different settings for what's shown on the dash as range: They have "Typical" and "Rated". US cars have "Ideal" and "Rated".
Also, the "Rated" milage does not mean the same thing in the European an US versions. The "Rated" version in the EU seem to map to "Ideal" in UK.

Do you make use of the flag that indicates whether the car is EU or US to display the range in your app?
 
Last edited:
As a developer who writes apps for Tesla, have you tried to write-off a portion of the cost of the car as business expense?

I haven't nor would I. It's kind of "outside the box" and when dealing with the I.R.S, they don't like that kind of thing.

But what I would suggest which I think is a more valid approach, would be using your car as a marketing tool to advertise your app or service. If you drive to Tesla group events, slap some vinyl stickers on the side, and write off the mileage. YMMV, consult your tax person for sure.
 
  • Like
Reactions: f8K37Sq31
Well, this sucks: Just checked the API after upgrading to 8.1 and saw that the "battery_current" API field of charge_state has been removed. This was quite useful for tracking vehicle state; I guess that's the risk of using an undocumented and unsupported API.
I really hope this is not true/ a mistake/ whatever. They can keep the sun roof state to vent, fine. But this is the last straw. Removing battery_current is going to break pretty much every graphing script that logs the cars movements. Really pissed off Tesla is starting to rope in the capabilities of the API.
 
Curious as how battery_current relates to logging car movement
It's kind of the foundation upon which the other information is built. It might look unimportant since it's underground and covered by wall finishings, but it's sure important, all right.

But, since it's already status data from an already cooked source (the car), some of the 3rd party app developers are wondering if they can back-calculate a good enough approximation from other communicated data. One developer already said that the now missing data was so high quality that they were using it for lots of uses, and that they haven't yet found other variables that contain the same level of quality in them to derive the old functionality. Kind of like replacing a foundation with stilts but the stilts are off-centered and leaning over and not tied into the home, so it could fall off in an earthquake or something, or they used bungie cords to make it at least stay close in an earthquake. Ok, I stretched the analogy.
 
Current = Power / voltage

Power and Voltage are both available.

Neither battery power nor battery voltage are available in the API. See JSON list in post above. While supercharging or CHADEMO, one can assume battery voltage is the charging voltage. The battery current is still not known as there may be large loads (heater or cooling) running which subtract off of charging current leaving an unknown battery current.