Skip to main content

Communicate with Tesla's official API

Project description

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

  1. Get a hold of your client ID and refresh token
  2. Import the TeslaService (and any other service you'll be using) from modelpy
    from modelpy import TeslaService
    from modelpy.vehicle import VehicleService
    
  3. Instantiate the TeslaService for your client ID
    tesla = TeslaService("abcd1234-5678-9abc-defg-hijklmnopqrst")
    
  4. Create your other services using the TeslaService
    vehicle_service = VehicleService(tesla)
    
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelpy-0.1.2b0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelpy-0.1.2b0-py2.py3-none-any.whl (11.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file modelpy-0.1.2b0.tar.gz.

File metadata

  • Download URL: modelpy-0.1.2b0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.2 CPython/3.13.3 Linux/6.11.0-1014-azure

File hashes

Hashes for modelpy-0.1.2b0.tar.gz
Algorithm Hash digest
SHA256 d16c57e3b4d25289283f962bcb242a63f7e9e3d70c8723c33134a93321a28544
MD5 66562251330a93947b15c149ec508af6
BLAKE2b-256 0c3e819d40121f632027939a093bba861a4825a2e686a2aca29beae8614bbabf

See more details on using hashes here.

File details

Details for the file modelpy-0.1.2b0-py2.py3-none-any.whl.

File metadata

  • Download URL: modelpy-0.1.2b0-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.2 CPython/3.13.3 Linux/6.11.0-1014-azure

File hashes

Hashes for modelpy-0.1.2b0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1ebe85440bc55395f9ceb909ec5c7b9e1fcfc4625a561f75ec122701bc7e75dc
MD5 faa099876633919d42f78a1d919be3a5
BLAKE2b-256 50879d06472b67b97e48b9fababcd02e8a9a4036ca2a3ceab9c0a76e495cedab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page