teslajsonpy
raw JSON → 3.13.2 verified Fri May 01 auth: no python
A Python library to interact with the Tesla API. It provides async access to vehicle data, controls (climate, charging, etc.), and energy products like Powerwall and solar. The current stable version is 3.13.2, supporting Python >=3.7. Release cadence is irregular, with several patches per year.
pip install teslajsonpy Common errors
error AttributeError: module 'teslajsonpy' has no attribute 'Tesla' ↓
cause Importing from the wrong module; common after upgrading from v1.x where the old class was TeslaClient.
fix
Use 'from teslajsonpy import Tesla' (v3.x) instead of 'from teslajsonpy import TeslaClient'.
error TypeError: object NoneType can't be used in 'await' expression ↓
cause Forgot to await an async call that returns a coroutine.
fix
Ensure all async methods are awaited: e.g., await tesla.vehicles() not tesla.vehicles().
error aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized' ↓
cause Expired or invalid authentication token.
fix
Re-authenticate with await tesla.connect() using valid email and password.
Warnings
breaking Version 3.x switched from synchronous to async API. All method calls must be awaited. ↓
fix Use async/await syntax and import from teslajsonpy (not teslajsonpy2).
gotcha Tesla API tokens expire after 45 days. The library does not automatically refresh; you must re-authenticate by calling connect() again. ↓
fix Periodically call await tesla.connect() before expiry, or catch token errors and re-authenticate.
gotcha Do not reuse a Tesla account with different API clients (e.g., both teslajsonpy and another app) - it can cause token invalidation. ↓
fix Use separate Tesla accounts for different integrations, or implement token sharing with care.
Imports
- Tesla
from teslajsonpy import Tesla - TeslaClient
from teslajsonpy import TeslaClient - Vehicle
from teslajsonpy import Vehicle - EnergySite
from teslajsonpy import EnergySite
Quickstart
import asyncio
from teslajsonpy import Tesla
import os
async def main():
email = os.environ.get('TESLA_EMAIL', '')
password = os.environ.get('TESLA_PASSWORD', '')
tesla = Tesla(email, password)
await tesla.connect()
vehicles = await tesla.vehicles()
for v in vehicles:
print(f'Vehicle: {v.display_name}, VIN: {v.vin}')
await tesla.disconnect()
asyncio.run(main())