How to Build a Tesla Data Dashboard with the Tesla API
By: Jamie Bailey
Tags: Technology, Dashboard, Internet of Things, Data Visualization, Tesla

*Update 11/13/2020: Unfortunately, Tesla has started restricting access to their API through most major services including AWS. This decision has broken this tutorial.

Introduction

If you own a Tesla, there is a good chance you fell in love with all of the advanced technology your vehicle puts at your fingertips. Geeking out about all of the things your car can do has become a favorite pastime of Tesla owners. While autopilot, sentry mode, auto-presenting door handles, frequent firmware updates, ludicrous mode, easter eggs, etc. are all go-tos when showing off unique capabilities, there is one really amazing feature that you probably haven’t taken advantage of yet — the Tesla API.

Tesla’s instrumentation panels give you unmatched real-time information about what is happening in and around your car while you drive. However, it cannot let you see a historical log of information like where you have been, your battery charge history, or how hot/cold it got in your car last night. Your Tesla cannot do things like automatically text your child when you are arriving to pick them up from swim practice. Or can it?

This tutorial will show you how you can connect your Tesla to a web service to do these things and more. This tutorial will leverage Initial State as the connecting web service since Initial State provides a simple, codeless Tesla API integration.

Background Info: Initial State

Initial State is an Internet of Things platform for data visualizations. You can stream real-time data into your Initial State account and build dashboards and custom trigger alerts from your data. There are several nifty integrations with other services that let you build your dashboards/triggers with data from those services with only a couple of clicks (i.e. no coding required). The Tesla API integration is particularly useful for this tutorial. Initial State has a 14-day free trial and costs $8.33/mo for a paid account unless you are a student, then it is free.

Background Info: Tesla API

Like all good, web-connected software, Tesla has an API. This API is used by the Tesla app and their internal diagnostics tools. However, Tesla does not publicly support this API and provide official documentation. That has not stopped the Tesla community from reverse engineering their API endpoints and providing excellent documentation (e.g. https://www.teslaapi.io ). The information available through this API is extremely useful and interesting. Your vehicle’s information is secured by your Tesla credentials, specifically OAuth, a standard protocol for authorization. This means you (and Tesla) are in control of your vehicle’s information.

Getting Started

Initial State account registration

The first step to getting started is to create an Initial State account. Go to https://www.initialstate.com and click on the GET STARTED button to register for an account. This will start a 14-day free trial. You do not need to enter anything other than your email address and a password to create an account and go through this tutorial.

Initial State app landing page after account creation

After creating an account, you will be automatically logged in to the Initial State web app, which will look similar to the screenshot above. To get to the data integrations section, click on the View all integrations link or go to https://integrations.initialstate.com . This is where you will find the Tesla API integration. Click on the Tesla integration, then the Begin Setup button.

Tesla API authorization

To use this data integration, you will need to authorize it by clicking on the Authorize button and entering your Tesla login information. This will generate an OAuth access token and allow access to your Tesla vehicle’s information.

Tesla integration setup — authorizing your Tesla

Once authorization is successful, you will return to the setup page where you should see that you successfully authorized your Tesla. Let’s complete the setup.

Tesla integration setup — starting the integration

Click the Begin Setup button to set up the integration parameters. Fill out the required information on the right

Give your integration a name (e.g. Tesla Vehicle Data).

Select your vehicle from the drop-down (required).

Leave Create a new bucket selected under “Choose a Bucket”.

Leave All available data selected under “What data would you like?”. This will pull in all available information from the Tesla API.

Select Every minute under “How often do you want new data?”. This is how often data will be fetched from your Tesla.

Click Start Integration at the bottom right to start receiving data from your Tesla. You are ready to start viewing your Tesla data. Return to the app starting page by clicking on the icon in the top left.

Tesla integration setup complete

A data bucket containing your Tesla data will be automatically created and shown in the bucket shelf on the left. Click on this data bucket to open up a dashboard of your Tesla data.

Tesla data dashboard

Your dashboard will look something like the one above. This dashboard only shows data since you started your integration. Hop in your car and drive around to start collecting some interesting data.

Create a Mobile Optimized Dashboard

The default dashboard created is great for viewing on your desktop but terrible for viewing on your phone. Let’s create a second view of your data optimized for your phone.

Data bucket settings

Click the bucket shelf icon on the top left to show a list of your data buckets. Click the settings icon under your Tesla Vehicle Data bucket.

Creating a duplicate dashboard view

Click the Duplicate button. Change the name to something like “Tesla Vehicle Data (Mobile)” in the top left and click the Create button at the bottom to create a duplicate view of your Tesla data.

Duplicated dashboard view

A second data bucket will be shown in your bucket shelf, an identical copy of your other Tesla data view. Let’s change this duplicate copy’s view to a mobile optimized view.

Click on the settings link under the new data bucket. Next, click on the Import View button.

Importing a mobile template

Paste the following URL in the input field at the top: https://go.init.st/7uzcl7i . This is a dashboard template built for a Tesla mobile view. Click on the “Tesla Data (mobile)” link below the input field and then click the Import button at the bottom to import this template.

Tesla Mobile Dashboard

Log in to your Initial State account on your phone and open the mobile dashboard view. It should look like the above screenshot. The same Tesla data will drive both the desktop and mobile dashboard. If you are using an iOS device, you can add an icon to your home screen and get rid of the top and bottom toolbars for a fullscreen view by following the instructions here.

Cool Things You Can Do

In addition to having a nice looking web dashboard, this integration adds a couple of features to your Tesla that can be used for several applications. The biggest new capabilities are historical data storage and real-time triggers (e.g. text message / email alerts). Let’s go over some cool things you can do with these new features.

Create a detailed trip log