This repo is a simple Tesla REST api implementation in TypeScript.
It includes functions for automatically renewing the access token and waking up the car if it has gone into standby.
Install
npm i teslarestasync --save
Sample code in TypeScript
import {Tesla} from 'teslarestasync';
const vehicleId = '5...3';
const refreshToken = 'eyJh...45';
const tesla = new Tesla(vehicleId, refreshToken);
tesla.getChargeData((response) => {
console.log(response);
});
getChargeData(callback (response)) This function returns all readings related to charging the car including battery limit, charge miles, charge voltage, charge phases, current, charge management, and battery heater status (Documentation).
getVehicleData(callback (response)) This function returns all the readings of the car (Documentation).
Implementations of other endpoints will follow
startCharging(callback (response)) Starts vehicle charging. Vehicle must be plugged in, have power available, and not at charge limit (Documentation).
stopCharging(callback (response)) Stop vehicle charging. Vehicle must be charging (Documentation).
setChargingAmps(amps, callback (response)) Sets the charging ampere. Amps must be a number and 5 or more.
Implementations of other endpoints will follow