Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla Owner API Tutorial (All you need is your browser)

This site may earn commission on affiliate links.
5FAA8108-9515-426B-85AA-DB83B6A65E73.png It's back
 
Hey Guys,

I am trying to use the APIs via Postman. Below are the steps that I performed.

Step 1 - Authentication

API URL - https://owner-api.teslamotors.com/oauth/token

Header
- None

Request Parameters -
grant_type: password
client_id:e4a9949fcfa04068f59abb5a658f2bac0a3428e4652315490b659d5ab3f35a9e
client_secret:c75f14bbadc8bee3a7594412c31416f8300256d7668ea7e6e7f06727bfb9d220
email:<Tesla account email address>
password:<Tesla account password>​

Response -

Status
- 200

Body -

{
"access_token": "3fa1a87ee188.....",
"token_type": "bearer",
"expires_in": 3888000,
"refresh_token": "07392729c5a....",
"created_at": 1539786288
}​

upload_2018-10-17_10-42-53.png



Step 2 - Get list of vehicles

API URL - https://owner-api.teslamotors.com/api/1/vehicles

Header
- Authorization:Bearer {3fa1a87ee18883f} <-- Access token from the Auth response

Request Parameters
- None

Response -

Status
- 404

Body -
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>​

upload_2018-10-17_10-44-30.png


The step 2 fails and gives a 404 error. Is there anything I am missing here
 

Attachments

  • upload_2018-10-17_10-39-36.png
    upload_2018-10-17_10-39-36.png
    89.7 KB · Views: 217
  • upload_2018-10-17_10-40-56.png
    upload_2018-10-17_10-40-56.png
    82.4 KB · Views: 205
  • upload_2018-10-17_10-41-47.png
    upload_2018-10-17_10-41-47.png
    91.2 KB · Views: 217
Hi guys,
thanks for this great tutorial. For some reason i cant get it to list vehicle state, i am able to get the token & list vehicle.
i get an error 408
{
"response": null,
"error": "vehicle unavailable: {:error=>\"vehicle unavailable:\"}",
"error_description": ""
}


I triple checked my vehicle_id.

this is the sample of my code from postman

import requests

url = "https://owner-api.teslamotors.com/api/1/vehicles/XXX162609475XXXXX/data_request/vehicle_state"

querystring = {"vehicle_id":"XXX162609475XXXXX"}

payload = ""
headers = {
'Authorization': "Bearer xxxxxd875ab45c833db15bb6a15050fdc52215d647807870f2ccefef83fxxxxx",
'cache-control': "no-cache",
'Postman-Token': "abfb6064-7e9f-4858-9665-1604733c10de"
}

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)

Hope you can shed some light. Thanks in advance
 
Hi guys,
thanks for this great tutorial. For some reason i cant get it to list vehicle state, i am able to get the token & list vehicle.
i get an error 408
{
"response": null,
"error": "vehicle unavailable: {:error=>\"vehicle unavailable:\"}",
"error_description": ""
}


I triple checked my vehicle_id.

this is the sample of my code from postman

import requests

url = "https://owner-api.teslamotors.com/api/1/vehicles/XXX162609475XXXXX/data_request/vehicle_state"

querystring = {"vehicle_id":"XXX162609475XXXXX"}

payload = ""
headers = {
'Authorization': "Bearer xxxxxd875ab45c833db15bb6a15050fdc52215d647807870f2ccefef83fxxxxx",
'cache-control': "no-cache",
'Postman-Token': "abfb6064-7e9f-4858-9665-1604733c10de"
}

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)

Hope you can shed some light. Thanks in advance
never mind, now its working fine. probably something on Tesla's side
 
Hey Guys,

I am trying to use the APIs via Postman. Below are the steps that I performed.

Step 1 - Authentication

API URL - https://owner-api.teslamotors.com/oauth/token

Header
- None

Request Parameters -
grant_type: password
client_id:e4a9949fcfa04068f59abb5a658f2bac0a3428e4652315490b659d5ab3f35a9e
client_secret:c75f14bbadc8bee3a7594412c31416f8300256d7668ea7e6e7f06727bfb9d220
email:<Tesla account email address>
password:<Tesla account password>​

Response -

Status
- 200

Body -

{
"access_token": "3fa1a87ee188.....",
"token_type": "bearer",
"expires_in": 3888000,
"refresh_token": "07392729c5a....",
"created_at": 1539786288
}​

View attachment 344618


Step 2 - Get list of vehicles

API URL - https://owner-api.teslamotors.com/api/1/vehicles

Header
- Authorization:Bearer {3fa1a87ee18883f} <-- Access token from the Auth response

Request Parameters
- None

Response -

Status
- 404

Body -
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>​

View attachment 344620

The step 2 fails and gives a 404 error. Is there anything I am missing here
I am getting the same error message at Step 1. Pls help out
 
Got stuck on: https://owner-api.teslamotors.com/api/1/vehicles

I am using access code that I get from Step 1, but get error message below in the response headers indicating an issue with the access token. Pls help out

Server →nginx
Date →Sun, 09 Dec 2018 05:45:55 GMT
Content-Type →application/json
Transfer-Encoding →chunked
Connection →keep-alive
X-Frame-Options →SAMEORIGIN
X-XSS-Protection →1; mode=block
X-Content-Type-Options →nosniff
Cache-Control →no-store
Pragma →no-cache
WWW-Authenticate →Bearer realm="Doorkeeper", error="invalid_token", error_description="The access token is invalid"
X-Request-Id →3d59f598-b159-4521-a443-bc71abbd23e8
X-Runtime →0.005503