Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wzr1337/teslastreaming
tesla streamibg api for nodejs
https://github.com/wzr1337/teslastreaming
Last synced: about 1 month ago
JSON representation
tesla streamibg api for nodejs
- Host: GitHub
- URL: https://github.com/wzr1337/teslastreaming
- Owner: wzr1337
- License: mit
- Created: 2020-10-27T21:02:16.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-02T11:08:35.000Z (about 4 years ago)
- Last Synced: 2023-05-07T09:51:03.431Z (over 1 year ago)
- Language: JavaScript
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# TeslaStreaming
[![Build Status](https://travis-ci.com/wzr1337/teslaStreaming.svg?branch=master)](https://travis-ci.com/wzr1337/teslaStreaming)
This module is used to connect to and listen on the Tesla streaming API, exposed via WebSocket. The API is a convenience method in extension of the regular REST API (), which needs to be polled.
This module is **UNOFFICIAL**.
## prerequisites
In order to use the streaming API, you need to obtain an `access_token` via the auth REST API.
## Installation
Add this module to your project using
`$ npm i teslastreaming`
## Usage
The following example stores a log of messages into an array, a very basic logger if you will:
```typescript
import { teslaAPI } from "./index";const vehicleId = '';
const token = '';const messages = [];
teslaAPI(vehicleId, token).subscribe((event)=> {
messages.push(event);
console.log(`messages received: ${messages.length}`);
console.log(`Tesla says: ${JSON.stringify(event, null, 2)}`)
});
```