All Projects → mlowijs → tesla_api

mlowijs / tesla_api

Licence: MIT license
Lightweight Python API client for the Tesla API.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to tesla api

TeslaKit
Elegant Tesla API in Swift
Stars: ✭ 47 (-35.62%)
Mutual labels:  tesla, teslamotors
tesla.dart
Tesla Client Library for Dart
Stars: ✭ 28 (-61.64%)
Mutual labels:  tesla, teslamotors
tesla-usb-drive
Tesla DashCam & Music USB drive maker tool
Stars: ✭ 17 (-76.71%)
Mutual labels:  tesla, teslamotors
TeslaPy
A Python module to use the Tesla Motors Owner API
Stars: ✭ 216 (+195.89%)
Mutual labels:  tesla, teslamotors
connectapi
An R package for interacting with the RStudio Connect Server API
Stars: ✭ 26 (-64.38%)
Mutual labels:  api-client
closeio-api
Python API Client for Close
Stars: ✭ 53 (-27.4%)
Mutual labels:  api-client
pywnedpasswords
Checkt pwnedpasswords.com in a secure way
Stars: ✭ 22 (-69.86%)
Mutual labels:  api-client
braze-php-sdk
A PHP client to interact with Braze API
Stars: ✭ 15 (-79.45%)
Mutual labels:  api-client
CryptoCurrency.Net
CryptoCurrency.Net
Stars: ✭ 21 (-71.23%)
Mutual labels:  api-client
FTAPIKit
Declarative and generic REST API framework using Codable.
Stars: ✭ 18 (-75.34%)
Mutual labels:  api-client
tiktok-scraper-php
Tiktok (Musically) PHP scraper
Stars: ✭ 65 (-10.96%)
Mutual labels:  api-client
wporg-client
Standalone HTTP client for public WordPress.org API.
Stars: ✭ 73 (+0%)
Mutual labels:  api-client
tesla-api
Unofficial API Wrapper for Tesla Model S and X. #follows-javascript-conventions #es6 #es7
Stars: ✭ 24 (-67.12%)
Mutual labels:  tesla
Jib.jl
A Julia implementation of Interactive Brokers API
Stars: ✭ 42 (-42.47%)
Mutual labels:  api-client
pyracing
A complete overhaul of the original ir_webstats; pyracing is an API client/wrapper for iRacing, the leading online simracing service. pyracing handles the queries to iRacing's (known) URL endpoints and maps the returned JSON data into structured objects, allowing for easier access to the data.
Stars: ✭ 52 (-28.77%)
Mutual labels:  api-client
dnsimple-python
The DNSimple API client for Python.
Stars: ✭ 66 (-9.59%)
Mutual labels:  api-client
redash-api-client
Redash API Client written in Python
Stars: ✭ 36 (-50.68%)
Mutual labels:  api-client
airtable
Airtable API Client for Go
Stars: ✭ 25 (-65.75%)
Mutual labels:  api-client
jellyfin-apiclient-python
Python API Client for Jellyfin
Stars: ✭ 30 (-58.9%)
Mutual labels:  api-client
kdecole-api
Unofficial Node.js API client of Kdecole (Skolengo EMS)
Stars: ✭ 31 (-57.53%)
Mutual labels:  api-client

Tesla API

This is a package for connecting to the Tesla API.

Usage for a vehicle

import asyncio
from tesla_api import TeslaApiClient

async def main():
    async with TeslaApiClient('[email protected]', 'yourPassword') as client:
        vehicles = await client.list_vehicles()

        for v in vehicles:
            print(v.vin)
            await v.controls.flash_lights()

asyncio.run(main())

Usage for Powerwall 2

import asyncio
from tesla_api import TeslaApiClient

async def main():
    client = TeslaApiClient('[email protected]', 'yourPassword')

    energy_sites = await client.list_energy_sites()
    print("Number of energy sites = %d" % (len(energy_sites)))
    assert(len(energy_sites)==1)
    reserve = await energy_sites[0].get_backup_reserve_percent()
    print("Backup reserve percent = %d" % (reserve))
    print("Increment backup reserve percent")
    await energy_sites[0].set_backup_reserve_percent(reserve+1)

    await client.close()

asyncio.run(main())

Reusing API tokens

To avoid needing to store login details, you can pass in a previous API token. Each time a new API token is created (either from a new login, or by refreshing an expired token), the on_new_token callback will be called.

async def save_token(token):
    open("token_file", "w").write(token)

async def main():
    email = password = token = None
    try:
        token = open("token_file").read()
    except OSError:
        email = input("Email> ")
        password = input("Password> ")
    client = TeslaApiClient(email, password, token, on_new_token=save_token)
    ...

If you only want to verify and save a user's token for later use, you could use the authenticate() method:

async def main():
    async with TeslaApiClient(email, password, on_new_token=save_token) as client:
        await client.authenticate()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].