Communicate with Tesla's official API
Project description
⚠️ Project Status: Archived
This project, MODELpY, is no longer being actively maintained. Development has ceased as I no longer own a Tesla, which was essential for testing and continued work on this project.
The repository remains available for reference and historical interest. Feel free to fork or build upon it if it's helpful to your own work!
MODELpY
An unofficial Python library for Tesla's official Fleet API.
Supported Functionality
- Authentication
- Fleet Configuration
- Vehicle Endpoints
- Vehicle Commands
- Charging Endpoints
- Energy Endpoints
- User Endpoints
- Partner Endpoints
Features
- Automatically refreshes your token to avoid your code failing after an extended period of time
- All that is needed to start interacting with your Tesla products is a client ID and a refresh token
- JSON responses are return as Models complete with typing
- Full JSON data is also accessible so new API functionality may be immediately supported
Usage
- Get a hold of your client ID and refresh token
- This is done by Creating an Application
- I won't include setup instructions here, but TeslaMate makes it fairly painless
- Import the TeslaService (and any other service you'll be using) from
modelpyfrom modelpy import TeslaService from modelpy.vehicle import VehicleService
- Instantiate the TeslaService for your client ID
tesla = TeslaService("abcd1234-5678-9abc-defg-hijklmnopqrst")
- Create your other services using the TeslaService
vehicle_service = VehicleService(tesla)
- Now you are ready to interact with the API endpoints
from modelpy import TeslaService from modelpy.vehicle import VehicleService tesla = TeslaService("abcd1234-5678-9abc-defg-hijklmnopqrst") vehicle_service = VehicleService(tesla) print(vehicle_service.vehicle())
TODO
- Paginated results are not yet supported
- The North American servers are hardcoded in at the moment
- Encrypt stored token
- Use access tokens more and refresh tokens less
Caveats
- The vehicle subscription endpoints are not supported and will remain that way unless I discover additional documentation
- Your refresh token is stored in plaintext so anyone with access to your device could have full access to your account
- Many scenarios will remain untested as I cannot simulate Tesla's responses with my limited products
- Tesla's docs are sometimes inconsistent or seemingly mistyped, again I can only confirm that I have programmed to align with said documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelpy-0.1.3b0.tar.gz.
File metadata
- Download URL: modelpy-0.1.3b0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.14.0 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc7cf69266f6c530b55fa4422ec148874e5e056971f2cb3696565fa03d1d44fd
|
|
| MD5 |
af637f639fe446090b7b3cfd20d99769
|
|
| BLAKE2b-256 |
f6e8a7bb1637c705a3dc3e9bbb574286da80e6addfc4a44f7e496b4bb1bcf718
|
File details
Details for the file modelpy-0.1.3b0-py2.py3-none-any.whl.
File metadata
- Download URL: modelpy-0.1.3b0-py2.py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.14.0 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81fe13e5c45f4732d82333050295a3b1acac301e8cde02b9180c78754c2bed46
|
|
| MD5 |
f4a40ebef3a8d2330048ba84fb481c9a
|
|
| BLAKE2b-256 |
3c19654c0beb50cffb6e0f3ef3ba4ca4f883bead52f30390eab1c9cfa6952223
|