forked from timdorr/tesla-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
712 lines (489 loc) · 18.9 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
FORMAT: 1A
HOST: https://owner-api.teslamotors.com
# Tesla Model S JSON API
This is unofficial documentation of the Tesla Model S JSON API used by the iOS and Android apps. It features functionality to monitor and control the Model S remotely.
# Group Authentication
## Tokens [/oauth/token]
### Get an Access Token [POST]
Performs the login. Takes in an plain text email and password, matching the owner's login information for [https://my.teslamotors.com/user/login](https://my.teslamotors.com/user/login).
Returns a `access_token` which is passed along as a header with all future requests to authenticate the user.
You must provide the `Authorization: Bearer {access_token}` header in all other requests.
The current client ID and secret are [available here](http://pastebin.com/fX6ejAHd)
+ Attributes
+ grant_type: `password` (string) - The type of oAuth grant. Always "password"
+ client_id: `abc` (string) - The oAuth client ID
+ client_secret: `123` (string) - The oAuth client secret
+ email: `elon@teslamotors.com` (string) - The email for my.teslamotors.com
+ password: `edisonsux` (string) - The password for my.teslamotors.com
+ Response 200 (application/json)
+ Body
{
"access_token": "abc123",
"token_type": "bearer",
"expires_in": 7776000,
"created_at": 1457385291
}
# Group Vehicles
A logged in user can have multiple vehicles under their account. This resource is primarily responsible for listing the vehicles and the basic details about them.
## Vehicle Collection [/api/1/vehicles]
### List all Vehicles [GET]
Retrieve a list of your owned vehicles (includes vehicles not yet shipped!)
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Response 200 (application/json)
+ Body
{
"response": [{
"color": null,
"display_name": null,
"id": 321,
"option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",
"user_id": 123,
"vehicle_id": 1234567890,
"vin": "5YJSA1CN5CFP01657",
"tokens": ["x", "x"],
"state": "online"
}],
"count":1
}
## State and Settings [/api/1/vehicles/{vehicle_id}]
These resources are read-only and determine the state of the vehicle's various sub-systems.
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
## Mobile Access [GET /api/1/vehicles/{vehicle_id}/mobile_enabled]
Determines if mobile access to the vehicle is enabled.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": true
}
## Charge State [GET /api/1/vehicles/{vehicle_id}/data_request/charge_state]
Returns the state of charge in the battery.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"charging_state": "Complete", // "Charging", ??
"charge_to_max_range": false, // current std/max-range setting
"max_range_charge_counter": 0,
"fast_charger_present": false, // connected to Supercharger?
"battery_range": 239.02, // rated miles
"est_battery_range": 155.79, // range estimated from recent driving
"ideal_battery_range": 275.09, // ideal miles
"battery_level": 91, // integer charge percentage
"battery_current": -0.6, // current flowing into battery
"charge_starting_range": null,
"charge_starting_soc": null,
"charger_voltage": 0, // only has value while charging
"charger_pilot_current": 40, // max current allowed by charger & adapter
"charger_actual_current": 0, // current actually being drawn
"charger_power": 0, // kW (rounded down) of charger
"time_to_full_charge": null, // valid only while charging
"charge_rate": -1.0, // float mi/hr charging or -1 if not charging
"charge_port_door_open": true
}
}
## Climate Settings [GET /api/1/vehicles/{vehicle_id}/data_request/climate_state]
Returns the current temperature and climate control state.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"inside_temp": 17.0, // degC inside car
"outside_temp": 9.5, // degC outside car or null
"driver_temp_setting": 22.6, // degC of driver temperature setpoint
"passenger_temp_setting": 22.6, // degC of passenger temperature setpoint
"is_auto_conditioning_on": false, // apparently even if on
"is_front_defroster_on": null, // null or boolean as integer?
"is_rear_defroster_on": false,
"fan_status": 0 // fan speed 0-6 or null
}
}
## Driving and Position [GET /api/1/vehicles/{vehicle_id}/data_request/drive_state]
Returns the driving and position state of the vehicle.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"shift_state": null, //
"speed": null, //
"latitude": 33.794839, // degrees N of equator
"longitude": -84.401593, // degrees W of the prime meridian
"heading": 4, // integer compass heading, 0-359
"gps_as_of": 1359863204 // Unix timestamp of GPS fix
}
}
## GUI Settings [GET /api/1/vehicles/{vehicle_id}/data_request/gui_settings]
Returns various information about the GUI settings of the car, such as unit format and range display.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"gui_distance_units": "mi/hr",
"gui_temperature_units": "F",
"gui_charge_rate_units": "mi/hr",
"gui_24_hour_time": false,
"gui_range_display": "Rated"
}
}
## Vehicle State [GET /api/1/vehicles/{vehicle_id}/data_request/vehicle_state]
Returns the vehicle's physical state, such as which doors are open.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"df": false, // driver's side front door open
"dr": false, // driver's side rear door open
"pf": false, // passenger's side front door open
"pr": false, // passenger's side rear door open
"ft": false, // front trunk is open
"rt": false, // rear trunk is open
"car_verson": "1.19.42", // car firmware version
"locked": true, // car is locked
"sun_roof_installed": false, // panoramic roof is installed
"sun_roof_state": "unknown",
"sun_roof_percent_open": 0, // null if not installed
"dark_rims": false, // gray rims installed
"wheel_type": "Base19", // wheel type installed
"has_spoiler": false, // spoiler is installed
"roof_color": "Colored", // "None" for panoramic roof
"perf_config": "Base"
}
}
# Group Vehicle Commands
These commands alter the vehicles state, and return result (true/false) to indicate success, and if failure reason contains the cause of failure.
## Wake Up Car [POST /api/1/vehicles/{vehicle_id}/wake_up]
Wakes up the car from the sleep state. Necessary to get some data from the car.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Set Valet Mode [POST /api/1/vehicles/{vehicle_id}/command/set_valet_mode]
Sets valet mode on or off with a PIN to disable it from within the car. Reuses last PIN from previous valet session.
Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. It also disables Homelink, Bluetooth and
Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work
locations in navigation.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ on: true (boolean) - Whether to enable or disable valet mode.
+ password: 1234 (number) - (optional) A 4 digit PIN code to unlock the car.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Reset Valet PIN [POST /api/1/vehicles/{vehicle_id}/command/reset_valet_pin]
Resets the PIN set for valet mode, if set.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Open Charge Port [POST /api/1/vehicles/{vehicle_id}/command/charge_port_door_open]
Opens the charge port. Does not close the charge port (for now...)
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Set Charge Limit to Standard [POST /api/1/vehicles/{vehicle_id}/command/charge_standard]
Set the charge mode to standard (90% under the new percentage system introduced in 4.5).
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": false,
"reason": "already_standard"
}
}
## Set Charge Limit to Max Range [POST /api/1/vehicles/{vehicle_id}/command/charge_max_range]
Set the charge mode to max range (100% under the new percentage system introduced in 4.5). Use sparingly!
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": false,
"reason": "already_max_range"
}
}
## Set Charge Limit [POST /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value}]
Set the charge limit to a custom percentage.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ limit_value: `75` (number) - The percentage value
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Start Charging [POST /api/1/vehicles/{vehicle_id}/command/charge_start]
Start charging. Must be plugged in, have power available, and not have reached your charge limit.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": "" // "already_started" if a charge is in progress
}
}
## Stop Charging [POST /api/1/vehicles/{vehicle_id}/command/charge_stop]
Stop charging. Must already be charging.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": "" // "not_charging" if a charge was not in progress
}
}
## Flash Lights [POST /api/1/vehicles/{vehicle_id}/command/flash_lights]
Flash the lights once.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Honk Horn [POST /api/1/vehicles/{vehicle_id}/command/honk_horn]
Honk the horn once.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Unlock Doors [POST /api/1/vehicles/{vehicle_id}/command/door_unlock]
Unlock the car's doors.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Lock Doors [POST /api/1/vehicles/{vehicle_id}/command/door_lock]
Lock the car's doors.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Set Temperature [POST /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC}]
Set the temperature target for the HVAC system.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ driver_degC: `23.7` (number) - The desired temperature on the driver's side in celcius.
+ pass_degC: `18.1` (number) - The desired temperature on the passenger's side in celcius.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Start HVAC System [POST /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start]
Start the climate control system. Will cool or heat automatically, depending on set temperature.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Stop HVAC System [POST /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop]
Stop the climate control system.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Move Pano Roof [POST /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent}]
Controls the car's panoramic roof, if installed.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ state: `open` (enum[string])
The desired state of the panoramic roof. The approximate percent open values for each state are `open` = 100%, `close` = 0%, `comfort` = 80%, and `vent` = ~15%
+ Members
+ `open` - Open the roof fully
+ `close` - Close the roof completely
+ `comfort` - Open to the comfort (80%) setting
+ `vent` - Open the roof to the vent (~15%) setting
+ `move` - Indicates you will provide a percentage to move the roof.
+ percent: `50` (number, optional) - The percentage to move the roof to.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Remote Start [POST /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password}]
Start the car for keyless driving. Must start driving within 2 minutes of issuing this request.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ password: `edisonsux` (string) - The password to the authenticated my.teslamotors.com account.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}
## Open Trunk/Frunk [POST /api/1/vehicles/{vehicle_id}/command/trunk_open]
Open the trunk or frunk. Currently inoperable.
+ Request
+ Headers
Authorization: Bearer {access_token}
+ Parameters
+ vehicle_id: `1` (number) - The id of the Vehicle.
+ which_trunk: `rear` (string) - The trunk to open. `rear` is the only one known currently.
+ Response 200 (application/json)
+ Body
{
"response": {
"result": true,
"reason": ""
}
}