<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>api Archives - Alexiev Arts</title>
	<atom:link href="https://alexievarts.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>https://alexievarts.com/tag/api/</link>
	<description>The official travel log/blog of the Alexiev family</description>
	<lastBuildDate>Sun, 03 Jan 2021 20:09:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://alexievarts.com/wp-content/uploads/2017/06/cropped-AlexievArts-32x32.png</url>
	<title>api Archives - Alexiev Arts</title>
	<link>https://alexievarts.com/tag/api/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Tesla Owners API &#8211; How To</title>
		<link>https://alexievarts.com/technology/tesla-owners-api-how-to/</link>
					<comments>https://alexievarts.com/technology/tesla-owners-api-how-to/#respond</comments>
		
		<dc:creator><![CDATA[Akrion]]></dc:creator>
		<pubDate>Mon, 15 Jul 2019 07:45:17 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tesla]]></category>
		<guid isPermaLink="false">https://alexievarts.com/?p=3992</guid>

					<description><![CDATA[<p>Tesla Owners API refers to an application programming interface provided by Tesla which when requests are made against it, it returns information related to your Tesla vehicle. The idea is to simply use the documentation services provided by Apiary.io and their testing tool to make the actual requests and see the responses. This has been [&#8230;]</p>
<p>The post <a href="https://alexievarts.com/technology/tesla-owners-api-how-to/">Tesla Owners API &#8211; How To</a> appeared first on <a href="https://alexievarts.com">Alexiev Arts</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-drop-cap">Tesla Owners API refers to an application programming interface provided by Tesla which when requests are made against it, it returns information related to your Tesla vehicle. The idea is to simply use the documentation services provided by <a rel="noreferrer noopener" href="https://apiary.io/" target="_blank">Apiary.io</a> and their testing tool to make the actual requests and see the responses. This has been extremely helpful to me personally. Tesla multiple times has failed me with their customer service and only the data from their servers was able to prove I was right in the related conversations. </p>



<h1 class="wp-block-heading">How is this useful?</h1>



<p>To give you one example: Tesla techs kept telling me that I had an upgrade that I did not have.  Only when I gave them the raw data from the API they understood that they have missed one. In another example I found out from the options codes returned from the API that I had a feature I did not know I had and it was not listed anywhere in the orientation or the invoice which came with the vehicle!</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Please note that this documentation is not official and in any shape or form supported or maintained by Tesla. It is actually reverse-engineered. The documentation web site Apiary is actually owned by Oracle and it is simply a product that helps with the documentation of application programming interfaces (or APIs). Also, none of your credentials are stored or kept anywhere. They are simply passed through to Tesla servers</p></blockquote>



<h1 class="wp-block-heading">How does this work?</h1>



<p>We will start with the following steps needed to get the information we want from the Tesla Owners API:</p>



<ul class="wp-block-list"><li>Authenticate via the <a aria-label="Apiary Tesla Owner JSON API (opens in a new tab)" rel="noreferrer noopener" href="https://akrion.docs.apiary.io/#reference/authentication/tokens/get-an-access-token?console=1" target="_blank">Apiary Tesla Owner JSON API</a> and get the authentication token we need in order to make any further requests to Tesla servers.</li><li>Once we have the token we would use that and add it to the header so our request can properly. authenticate against the Tesla servers and obtain the other pieces of information we need.</li><li>Get the list of vehicles under your account via the authentication token.</li><li>Using a vehicle id get the information of interest.</li></ul>



<h1 class="wp-block-heading">Step 1: Go to the Tesla Owner JSON API on Apiary.io</h1>



<p><a aria-label="Click on this link (opens in a new tab)" rel="noreferrer noopener" href="https://akrion.docs.apiary.io/#reference/authentication/tokens/get-an-access-token?console=1" target="_blank">Click on this link</a> and have the browser window open and handy so you can see the current one you are reading from and the new one where you would add/change values. The link is to the actual documentation website we would use to make the requests.</p>



<h1 class="wp-block-heading">Step 2: Get an authentication token from Tesla</h1>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01.jpg"><img fetchpriority="high" decoding="async" width="2209" height="1252" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01.jpg" alt="Tesla API 01" data-id="4000" class="wp-image-4000" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01.jpg 2209w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01-300x170.jpg 300w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01-768x435.jpg 768w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01-249x140.jpg 249w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-01-232x130.jpg 232w" sizes="(max-width: 2209px) 100vw, 2209px" /></a></figure></li></ul></figure>



<p>You should see the screen above. The left side of it is the actual documentation and every request is explained in detail there. On the right side is the console where we would actually perform the requests and see the responses. Since the link already pointed to the <strong>Get an Access Token </strong>request<strong> </strong>it is already open and ready to be executed on the right side. The <strong>header</strong> information is already added as well as the majority of the <strong>body</strong>. What is only missing is your <em>email and password</em>. Enter those where it says &#8220;YOUR_EMAIL&#8221; and &#8220;YOUR_PASSWORD&#8221; and <strong>click on the &#8220;Call Resource&#8221;</strong>. Again no information is kept on your request. Your credentials are simply passed through to Tesla from the Apiary servers. You should see the following response <strong>in the console section</strong>:</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-02.jpg"><img decoding="async" width="1179" height="1329" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-02.jpg" alt="" data-id="4004" class="wp-image-4004" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-02.jpg 1179w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-02-266x300.jpg 266w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-02-768x866.jpg 768w" sizes="(max-width: 1179px) 100vw, 1179px" /></a></figure></li></ul></figure>



<p>You should get a <strong>200</strong> response from the server (see the red rectangle in the image above). This means we did everything correctly and we now have received an authentication token from the Tesla servers. This is the <strong>access_token</strong> in the <strong>Response Body</strong> above (masked in this example). Copy the value of that access_token (copy the text between the &#8220;&#8221; for the <strong>access_token</strong> key).</p>



<h1 class="wp-block-heading">Step 3: Get the list of vehicles using the token</h1>



<p>Now that we have the token we would go to the <strong>Vehicles</strong> part of the documentation and click on the <strong>List all Vehicles</strong> request:</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-03.jpg"><img decoding="async" width="2191" height="473" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-03.jpg" alt="" data-id="4009" class="wp-image-4009" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-03.jpg 2191w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-03-300x65.jpg 300w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-03-768x166.jpg 768w" sizes="(max-width: 2191px) 100vw, 2191px" /></a></figure></li></ul></figure>



<p>In the console section, we would go to the Headers tab and for the Authorization key, we would set the value to be: Bearer and the token we copied from Step 1. That is all you need before clicking on the Call Resource again to this time to get the list of vehicles. Note that the Authorization value should not contain double quotes etc. Should be simply Bearer followed by space and the token value from Step 1. When you are done you should see something like this in the response:</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-04.jpg"><img loading="lazy" decoding="async" width="1177" height="1530" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-04.jpg" alt="" data-id="4012" class="wp-image-4012" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-04.jpg 1177w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-04-231x300.jpg 231w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-04-768x998.jpg 768w" sizes="auto, (max-width: 1177px) 100vw, 1177px" /></a></figure></li></ul></figure>



<p>All is well! We now have received the first few details about our car. We have the VIN, the actual Id in the Tesla system, the option codes, etc. Great result for a few minutes of actual &#8220;work&#8221; right?  You also can now compare and check if your option codes match your invoice :). Now that we have the vehicle list we can copy the <strong>id_s</strong> value from it and dive into the actual specific data of that vehicle.</p>



<h1 class="wp-block-heading">Step 4: Using the id_s to get vehicle data</h1>



<p>What we will do now is to utilize the <strong>token</strong> and the <strong>id_s</strong> to get any of the <strong>State and Settings</strong> data we would like.  We would only do the Vehicle State in this example since all others follow the same pattern. So two things we need to go forward with this. <strong>One</strong> is the authorization <strong>token</strong> we got from <strong>step 1</strong> and <strong>second</strong> the <strong>id_s</strong> we got from <strong>step 3</strong>. Let&#8217;s click on the <strong>Vehicle State</strong> in the <strong>State and Settings</strong> section of the documentation.</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05.jpg"><img loading="lazy" decoding="async" width="2186" height="1225" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05.jpg" alt="Tesla API 05" data-id="4015" class="wp-image-4015" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05.jpg 2186w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-300x168.jpg 300w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-768x430.jpg 768w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-366x205.jpg 366w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-534x300.jpg 534w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-165x92.jpg 165w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-249x140.jpg 249w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-232x130.jpg 232w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-05-344x193.jpg 344w" sizes="auto, (max-width: 2186px) 100vw, 2186px" /></a></figure></li></ul></figure>



<p>Here in the console, we would go to the URL Parameters and for the value of <strong>vehicle_id</strong>, we would set the value we got from <strong>step 3</strong> for the <strong>id_s</strong>. Then we would click on the <strong>Headers</strong> tab and do <strong>exactly what we did in step 3</strong>. Set the <strong>Authorization</strong> key to the <strong>Bearer</strong> and the token value from step 1. Clicking on <strong>Call Resource</strong> should return a response looking like this:<br></p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-06.jpg"><img loading="lazy" decoding="async" width="1160" height="1956" src="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-06.jpg" alt="" data-id="4016" class="wp-image-4016" srcset="https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-06.jpg 1160w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-06-178x300.jpg 178w, https://alexievarts.com/wp-content/uploads/2019/07/Tesla-API-06-768x1295.jpg 768w" sizes="auto, (max-width: 1160px) 100vw, 1160px" /></a></figure></li></ul></figure>



<p>As you can see this returns a lot more data related to the actual state of the vehicle. You can now follow this example and do any of the other requests listed under the State and Settings section. For the sake of brevity, we would not cover the Vehicle Commands section. It follows the same patterns overall so you can experiment if you like it.</p>



<p>Hope this helps and if you have any questions do not hesitate to post a comment. I will do my best to reply promptly. </p>



<h1 class="wp-block-heading">Use my referral code and save!</h1>



<p>If you would like to receive <strong>1,000 free Supercharger miles</strong> when you purchase your new Tesla use my referral code: <a rel="noreferrer noopener" aria-label="http://ts.la/ilian3072 (opens in a new tab)" href="http://ts.la/ilian3072" target="_blank">http://ts.la/ilian3072</a></p>
<p>The post <a href="https://alexievarts.com/technology/tesla-owners-api-how-to/">Tesla Owners API &#8211; How To</a> appeared first on <a href="https://alexievarts.com">Alexiev Arts</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://alexievarts.com/technology/tesla-owners-api-how-to/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
