Giter VIP home page Giter VIP logo

tesla-api's Introduction

@qualiture/tesla-api

An unofficial library that wraps the Tesla Owner's API

Warning!

This package was created for personal use!

Ever since Tesla changed its authentication mechanism mid 2021, I used a forked fix from https://www.npmjs.com/package/teslajs which mitigated that issue.

However, since January 22nd, 2023 that fix no longer worked and threw a HTTP 412 Precondition Failed error upon retrieving vehicle details. It appeared I'm not the only one suffering from that issue (see for instance issue teslamate-org/teslamate#3629)

And since the teslajs package seems no longer maintained, I took the plunge and created a simple package which suits my needs.

The most notable change is that getting vehicle data no longer works the old way (via GET /api/1/vehicles?page={page}).

Therefore, I'm now retrieving the products (via GET /api/1/products?orders=true) and in my specific case that returns an array of exactly one product, my vehicle :-)

As such, when you own more products (Tesla Wall, Solar, or multiple cars), you may want to adapt this package.

Installation

Simply use

npm i @qualiture/tesla-api

Library Usage

import TeslaAPI from "@qualiture/tesla-api";

const api = new TeslaAPI("<your access token>");

// Retrieves owner info
const owner = await api.getUser();

// Retrieves vehicle(s) info
const vehicles = await api.getOwnerVehicles();

// Retrieves vehicle data for first vehicle
const vehicleData = await api.getVehicleData(vehicles[0].id);

The library contains type definitions, so you could use it directly into your TypeScript project.

Have fun!

tesla-api's People

Contributors

qualiture avatar

Watchers

 avatar

tesla-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.