npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

teslats

v1.0.3

Published

Tesla API library written in TypeScript

Downloads

9

Readme

TeslaTS

Version License Dependencies

Unofficial NodeJS library with Type definitions in TypeScript that wraps the unofficial Tesla APIs.

Other good projects

If you dont one or more then the followings:

  • Promises
  • TypeScript definitions
  • Rx.js/like streams from tesla.

There is a very good and documented project written in javascript that tackles the tesla api very well. You can find it here

Rationale

I hate dealing with callbacks and JavaScript so when I (the Author) had to make my long journey to North Cape this winter at -30°C I wanted to build something I could use to track data in realtime and give my YouTube followers the chance to inspect real time informations about the car.

Through this library it was possible to build a telemetry website based on Grafana+InfluxDB where you can inspect all the informations gathered by this library.

Also thanks to this I was able to write other supplementary real-time API based informations such as the following:

Features.

  • Written entirely in TypeScript
  • Promises
  • Rxjs streams for realtime data-flow.

Contributing

Contributions are welcome, particularly bug fixes and enhancements!

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

Disclaimer

The project owner makes no warranties about the completeness, reliability and accuracy of its code. Using this library might be against the ToS of Tesla and you are the only responsible when dealing with sensitive data such as authentication credentials, tokens etc. Keeping the credentials secure is out of scope of this project. Keep in mind that through this library you'll be able to unlock your vehicle, remotely start it or worse. This is why the code included here comes with NO WARRANTY and you're using it AT YOUR OWN RISK.

If, at any time, you feel like your password/token was exposed. Make sure to change the password through the Tesla website. Be aware that this will also invalidate any existing tokens.

More infos about the Tesla APIs

The work of this library was made possible thanks to this, and this websites!

Installation

yarn install teslats

Usage

Best practices.

It's always preferred to use the token instead of the email and password when authenticating. So if you already own an access token use that when initializing this library. If you dont own a token you can issue a login (see example below) and then call the .credentials method, which will also output the token that can then be used.

Step 1. Login!

If you already own an access As you can see below, it is very simple to login and acquire an OAuth token.

    import { TeslaAPI } from 'teslats';
  
    const api = new TeslaAPI('<your email>', '<your Tesla Password>');
    // or use the token
    // const api = new TeslaAPI('<token>');

Step 2. Get Vehicles

    api.vehicles()
      .then((vehicles) => {
        console.log('my vehicles: ', vehicles);
        // get the first vehicle!
        const vehicle = vehicles[0];
      })
      .catch((error) => console.warn(error));

Step 3. Interact with them

    // const vehicle: VehicledData; // ^ comes from the previous example.
    vehicle.commands.setWindows('vent')
      .then((success) => console.log('Did it open the windows? ', success));

Powerwall Support

The library has support also for powerwalls/energy_sites. You can change the operating mode, the backup percentage (if available) and inspect live status along with the current powerwall+gateway configuration parameters.

Some of the APIs are energy_site relevant and others are powerwall relevant. This means that, in case of more than 1 powerwall attached to a site, some APIs (such as the live view) will return the aggregated informations amongst all batteries installed.

To interact with your Tesla batteries just check the code within src/powerwalls. You can acquire an API instance much like you do with vehicles:

   api.powerwalls().then((powerwalls) => console.log('powerwalls: ', powerwalls));

Documentation

There is no autogenerated documentation (yet). But this is the beauty of TypeScript. The code has been structured to be straight-forward to use and understand. All the code lives within the vehicleCommands.ts file to issue commands which could be accessed through a single Vehicle(API) instance.

Back to Top