{"id":24697,"library":"teslajsonpy","title":"teslajsonpy","description":"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.","status":"active","version":"3.13.2","language":"python","source_language":"en","source_url":"https://github.com/zabuldon/teslajsonpy","tags":["tesla","api","async","vehicle","powerwall","energy"],"install":[{"cmd":"pip install teslajsonpy","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Tesla","correct":"from teslajsonpy import Tesla"},{"note":"","wrong":"","symbol":"TeslaClient","correct":"from teslajsonpy import TeslaClient"},{"note":"","wrong":"","symbol":"Vehicle","correct":"from teslajsonpy import Vehicle"},{"note":"","wrong":"","symbol":"EnergySite","correct":"from teslajsonpy import EnergySite"}],"quickstart":{"code":"import asyncio\nfrom teslajsonpy import Tesla\nimport os\n\nasync def main():\n    email = os.environ.get('TESLA_EMAIL', '')\n    password = os.environ.get('TESLA_PASSWORD', '')\n    tesla = Tesla(email, password)\n    await tesla.connect()\n    vehicles = await tesla.vehicles()\n    for v in vehicles:\n        print(f'Vehicle: {v.display_name}, VIN: {v.vin}')\n    await tesla.disconnect()\n\nasyncio.run(main())","lang":"python","description":"Connects to Tesla API and lists available vehicles. Requires TESLA_EMAIL and TESLA_PASSWORD environment variables."},"warnings":[{"fix":"Use async/await syntax and import from teslajsonpy (not teslajsonpy2).","message":"Version 3.x switched from synchronous to async API. All method calls must be awaited.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Periodically call await tesla.connect() before expiry, or catch token errors and re-authenticate.","message":"Tesla API tokens expire after 45 days. The library does not automatically refresh; you must re-authenticate by calling connect() again.","severity":"gotcha","affected_versions":"all"},{"fix":"Use separate Tesla accounts for different integrations, or implement token sharing with care.","message":"Do not reuse a Tesla account with different API clients (e.g., both teslajsonpy and another app) - it can cause token invalidation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from teslajsonpy import Tesla' (v3.x) instead of 'from teslajsonpy import TeslaClient'.","cause":"Importing from the wrong module; common after upgrading from v1.x where the old class was TeslaClient.","error":"AttributeError: module 'teslajsonpy' has no attribute 'Tesla'"},{"fix":"Ensure all async methods are awaited: e.g., await tesla.vehicles() not tesla.vehicles().","cause":"Forgot to await an async call that returns a coroutine.","error":"TypeError: object NoneType can't be used in 'await' expression"},{"fix":"Re-authenticate with await tesla.connect() using valid email and password.","cause":"Expired or invalid authentication token.","error":"aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}