Skip to main content

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

  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.3b0.tar.gz (11.7 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.3b0-py2.py3-none-any.whl (11.8 kB view details)

Uploaded Python 2Python 3

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

Hashes for modelpy-0.1.3b0.tar.gz
Algorithm Hash digest
SHA256 cc7cf69266f6c530b55fa4422ec148874e5e056971f2cb3696565fa03d1d44fd
MD5 af637f639fe446090b7b3cfd20d99769
BLAKE2b-256 f6e8a7bb1637c705a3dc3e9bbb574286da80e6addfc4a44f7e496b4bb1bcf718

See more details on using hashes here.

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

Hashes for modelpy-0.1.3b0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 81fe13e5c45f4732d82333050295a3b1acac301e8cde02b9180c78754c2bed46
MD5 f4a40ebef3a8d2330048ba84fb481c9a
BLAKE2b-256 3c19654c0beb50cffb6e0f3ef3ba4ca4f883bead52f30390eab1c9cfa6952223

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