# MODELpY
An unofficial Python library for Tesla's official [Fleet API](https://developer.tesla.com/docs/fleet-api/).
## Supported Functionality
- [X] Authentication
- [X] Fleet Configuration
- [X] 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
1. Get a hold of your client ID and refresh token
- This is done by [Creating an Application](https://developer.tesla.com/docs/fleet-api/getting-started/what-is-fleet-api#step-2-create-an-application)
- I won't include setup instructions here, but [TeslaMate](https://www.myteslamate.com/) makes it fairly painless
2. Import the TeslaService (and any other service you'll be using) from `modelpy`
```python
from modelpy import TeslaService
from modelpy.vehicle import VehicleService
```
3. Instantiate the TeslaService for your client ID
```python
tesla = TeslaService("abcd1234-5678-9abc-defg-hijklmnopqrst")
```
4. Create your other services using the TeslaService
```python
vehicle_service = VehicleService(tesla)
```
5. Now you are ready to interact with the API endpoints
```python
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
Raw data
{
"_id": null,
"home_page": null,
"name": "MODELpY",
"maintainer": null,
"docs_url": null,
"requires_python": ">=2.7",
"maintainer_email": null,
"keywords": "tesla, model, S, 3, X, Y, Cybertruck, fleet, telemetry, api",
"author": null,
"author_email": "Cody M Sommer <bassmastacod@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ad/90/81d1594f64627360b4f301ddce30cca7305d3d7d372cafbc41037c39fb10/modelpy-0.1.1b0.tar.gz",
"platform": null,
"description": "# MODELpY\nAn unofficial Python library for Tesla's official [Fleet API](https://developer.tesla.com/docs/fleet-api/).\n\n## Supported Functionality\n- [X] Authentication\n- [X] Fleet Configuration\n- [X] Vehicle Endpoints\n- [ ] Vehicle Commands\n- [ ] Charging Endpoints\n- [ ] Energy Endpoints\n- [ ] User Endpoints\n- [ ] Partner Endpoints\n\n## Features\n- Automatically refreshes your token to avoid your code failing after an extended period of time\n- All that is needed to start interacting with your Tesla products is a client ID and a refresh token\n- JSON responses are return as Models complete with typing\n- Full JSON data is also accessible so new API functionality may be immediately supported\n\n## Usage\n1. Get a hold of your client ID and refresh token\n - This is done by [Creating an Application](https://developer.tesla.com/docs/fleet-api/getting-started/what-is-fleet-api#step-2-create-an-application)\n - I won't include setup instructions here, but [TeslaMate](https://www.myteslamate.com/) makes it fairly painless\n2. Import the TeslaService (and any other service you'll be using) from `modelpy`\n ```python\n from modelpy import TeslaService\n from modelpy.vehicle import VehicleService\n ```\n3. Instantiate the TeslaService for your client ID\n ```python\n tesla = TeslaService(\"abcd1234-5678-9abc-defg-hijklmnopqrst\")\n ```\n4. Create your other services using the TeslaService\n ```python\n vehicle_service = VehicleService(tesla)\n ```\n5. Now you are ready to interact with the API endpoints\n ```python\n from modelpy import TeslaService\n from modelpy.vehicle import VehicleService\n\n tesla = TeslaService(\"abcd1234-5678-9abc-defg-hijklmnopqrst\")\n vehicle_service = VehicleService(tesla)\n print(vehicle_service.vehicle())\n ```\n\n## TODO\n- [ ] Paginated results are not yet supported\n- [ ] The North American servers are hardcoded in at the moment\n- [ ] Encrypt stored token\n- [ ] Use access tokens more and refresh tokens less\n\n## Caveats\n- The vehicle subscription endpoints are not supported and will remain that way unless I discover additional documentation\n- Your refresh token is stored in plaintext so anyone with access to your device could have full access to your account\n- Many scenarios will remain untested as I cannot simulate Tesla's responses with my limited products\n- Tesla's docs are sometimes inconsistent or seemingly mistyped, again I can only confirm that I have programmed to align with said documentation\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Communicate with Tesla's official API",
"version": "0.1.1b0",
"project_urls": {
"Issues": "https://github.com/BassMastaCod/MODELpY/issues",
"Repository": "https://github.com/BassMastaCod/MODELpY.git"
},
"split_keywords": [
"tesla",
" model",
" s",
" 3",
" x",
" y",
" cybertruck",
" fleet",
" telemetry",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "389100c3f667a79b8d37240de0805861d055be8025de6973b924304d23d27379",
"md5": "cc89db150ac49f43c4484e2a74d63a05",
"sha256": "14b5a4f6eb36fa285b4e5c57421b29f861432a74e5dda0939707f13335fa9d68"
},
"downloads": -1,
"filename": "modelpy-0.1.1b0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc89db150ac49f43c4484e2a74d63a05",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=2.7",
"size": 11471,
"upload_time": "2025-01-17T16:43:13",
"upload_time_iso_8601": "2025-01-17T16:43:13.113655Z",
"url": "https://files.pythonhosted.org/packages/38/91/00c3f667a79b8d37240de0805861d055be8025de6973b924304d23d27379/modelpy-0.1.1b0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ad9081d1594f64627360b4f301ddce30cca7305d3d7d372cafbc41037c39fb10",
"md5": "b87043b991835434b1e47e8b1dbfa316",
"sha256": "4b75a1a87991750fc414c7f9c8e8e1dfe86e61d2bd2c8fbd94fee27b32e6c1fc"
},
"downloads": -1,
"filename": "modelpy-0.1.1b0.tar.gz",
"has_sig": false,
"md5_digest": "b87043b991835434b1e47e8b1dbfa316",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7",
"size": 11109,
"upload_time": "2025-01-17T16:43:15",
"upload_time_iso_8601": "2025-01-17T16:43:15.290772Z",
"url": "https://files.pythonhosted.org/packages/ad/90/81d1594f64627360b4f301ddce30cca7305d3d7d372cafbc41037c39fb10/modelpy-0.1.1b0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-17 16:43:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BassMastaCod",
"github_project": "MODELpY",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "modelpy"
}