Please consider Sponsoring TeslaJS!

TeslaJS.org

TeslaJS.orgTeslaJS.orgTeslaJS.org

TeslaJS.org

TeslaJS.orgTeslaJS.orgTeslaJS.org

An unofficial NodeJS library for Tesla products

The TeslaJS library currently supports all existing Tesla vehicles and Tesla Solar.


There are already several very good JavaScript libraries available for the Tesla. So why create another one? Rather than contribute to or modify one or more of the existing libraries, this library was created for a few reasons:


  1. The anticipated need for a few small but important features that existing libraries did not provide
  2. I was looking for a personal opportunity to learn more about the Tesla API, NodeJS, Express and Git/GitHub
  3. I was planning to write a Windows Store app for Tesla cars and I needed a core technology component that would meet those needs. You can learn more about the Tesla Control app here.


Notable Features


With the introduction of the new OAuth-based owner API, one of the features I wanted was the ability to make API calls without having to login each time a new process was invoked. Many existing libraries require a login transaction with each initiation of the library. With the TeslaJS library, once an auth token is retrieved it can be cached and used to make other Tesla API calls. For certain use cases, notably server logging of multiple vehicles, this can be important for moderating load on the Tesla login servers.


This is also important if you want to use the library to do server-based data logging. It is generally safer to store an OAuth token on the server rather than logon credentials. If the server is compromised only the OAuth token is at risk and all existing tokens can be invalidated by changing the password on the account.


Another feature that I wanted was API stateless-ness (achieved via an options parameter to API calls) so that it was possible to use the library to make multiple overlapping async calls to different vehicles for data-logging.


Project Principles


This project has a few principles that have and will continue to guide its development.

  1. Dependency lean. Try to keep the required dependencies to a minimum.
  2. Comprehensive. Attempt to expose the full Tesla REST API surface area.
  3. Simple. Using the library should be simple and straightforward following common conventions.
  4. Server friendly. Provide for use based on auth tokens and avoid requiring access to passwords.


Documentation


We've recently added auto-generated documentation via jsdocs. See the DOCS for a mostly complete reference. Please let us know if you see something missing and we will continue to expand.


Contributing


Contributions are welcome, particularly bug fixes and enhancements! Refer to our Contribution Guidelines for details.


Please note that the Project owners reserve the right to accept or reject any PR for any reason.

Code of Conduct


Before contributing or participating in the TeslaJS community please be sure to familiarize yourself with our project CODE OF CONDUCT. These guidelines are intended to govern interactions with and within the TeslaJS community.


Tesla API Documentation


The Tesla API encapsulated by this library was documented through the collaboration of many Tesla owners. Please thank and support them for their continued efforts! The latest API documentation can be found here.


Warranty Disclaimer


You may use this library with the understanding that doing so is AT YOUR OWN RISK. No warranty, express or implied, is made with regards to the fitness or safety of this code for any purpose. If you use this library to query or change settings of your vehicle you understand that it is possible to make changes that could inadvertently lower the security of your vehicle, or cause damage, through actions including but not limited to:


  • Unlocking the vehicle
  • Remotely starting the vehicle
  • Opening the sunroof
  • Opening the windows
  • Opening the frunk or trunk
  • Raising or lowering the battery charge level
  • Impacting the long-term health of your battery

Get the library

Connect With Us

Copyright © 2021 TeslaJS.org - All Rights Reserved.

Powered by GoDaddy Website Builder