Skip to main content

Python library and CLI for communicating with Porsche Connect API.

Project description

pyporscheconnectapi

A python library for Porsche Connect API

This library will let you access your car equipped with Porsche Connect. It does not work with the predecessor Porsche Car Connect. Porsche Connect is available for the following Porsche models:

  • Taycan
  • 911 (from 992)
  • Cayenne (from 2017, E3)
  • Panamera (from 2021, G2 PA)

You can also take a look here, select your model and see if your model has support for Porsche Connect: https://connect-store.porsche.com/

A Porsche Connect subscription alse needs to be active for it to work.

NOTE: This work is not officially supported by Porsche and functionality can stop working at any time without warning

Installation

The easiest method is to install using pip3/pip (venv is also a good idea)

pip install pyporscheconnectapi

to update to the latest version

pip install pyporscheconnectapi -U

Setup will add a cli under the name porschecli, see below for usage

CLI usage

A simple cli is provided with this library, it will cache tokens to a file to speed up invocations. It does not yet support the create/update/delete timer functionality which is present in the library.

If no email or password is supplied as input arguments and no config file with those details is found you will be prompted. Same goes for PIN (used to lock or unlock). The --nowait option will just request the action (or stored information) without waiting for confirmation.

usage: cli.py [-h] [-e EMAIL] [-p PASSWORD] [-s SESSION_FILE] [-v VIN]
              [-n PIN] [-m MODEL] [-a] [-c COUNTRY] [-l LANGUAGE]
              [-z TIMEZONE] [--nowait]
              {list,overview,maintenance,summary,capabilities,emobility,position,triplongterm,tripshortterm,speedalerts,theftalerts,tokens,lock,unlock,climate-on,climate-off,directcharge-on,directcharge-off}

Porsche Connect CLI.

positional arguments:
  {list,overview,maintenance,summary,capabilities,emobility,position,triplongterm,tripshortterm,speedalerts,theftalerts,tokens,lock,unlock,climate-on,climate-off,directcharge-on,directcharge-off}

optional arguments:
  -h, --help            show this help message and exit
  -e EMAIL, --email EMAIL
  -p PASSWORD, --password PASSWORD
  -s SESSION_FILE, --sessionfile SESSION_FILE
  -v VIN, --vin VIN
  -n PIN, --pin PIN
  -m MODEL, --model MODEL
  -a, --all
  -c COUNTRY, --country COUNTRY
  -l LANGUAGE, --language LANGUAGE
  -z TIMEZONE, --timezone TIMEZONE
  --nowait

Config file (for CLI)

A config file is searched for in ~/.porscheconnect.cfg and ./.porscheconnect.cfg The format is:

[porsche]
email=<your email>
password=<your password>
country=<country iso code, default DE>
language=<lang abbreviation, default de>
timezone=<default Europe/Stockholm>

Library usage

Install pyporscheconnectapi using pip (requires python > 3.6)

Example client usage

import asyncio
from pyporscheconnectapi.connection import Connection
from pyporscheconnectapi.client import Client
email = ..your porsche connect email...
password = ...your porsche connect password...

async def vehicles() -> None:
    conn = Connection(email, password)
    client = Client(conn)

    vehicles = await client.getVehicles()
    for vehicle in vehicles:
        print(f"VIN: {vehicle['vin']} Model: {vehicle['modelDescription']} Year: {vehicle['modelYear']}")

    await conn.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(vehicles())

Example connection usage for custom requests

import asyncio
from pyporscheconnectapi.connection import Connection
from pyporscheconnectapi.client import Client
email = ..your porsche connect email...
password = ...your porsche connect password...

async def vehicles() -> None:
    conn = Connection(email, password)
    client = Client(conn)

    vehicles = await client.getVehicles()
    for vehicle in vehicles:
        print(f"VIN: {vehicle['vin']} Model: {vehicle['modelDescription']} Year: {vehicle['modelYear']}")
        # Using connection.get will automatically add auth headers
        data = await conn.get(f"https://api.porsche.com/core/api/v3/se/sv_SE/vehicles/{vehicle['vin']}")
        print(f"Battery at {data['carControlData']['batteryLevel']['value']}%")

    await conn.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(vehicles())

Credits

evcc was a good resource for figuring out the Authentication flow

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

pyporscheconnectapi-0.1.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

pyporscheconnectapi-0.1.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file pyporscheconnectapi-0.1.1.tar.gz.

File metadata

  • Download URL: pyporscheconnectapi-0.1.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for pyporscheconnectapi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 106d0ca6ee6b4e19b93619826e8939172063fed461afef7af04f0750abad2090
MD5 60a4b30a4b6744b9d7c9f4b0fe15d7d9
BLAKE2b-256 185760589e2f194bf73a1272ae5055cfbfdf830a199dab85538bec3f3062acc8

See more details on using hashes here.

File details

Details for the file pyporscheconnectapi-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyporscheconnectapi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c482c7b9a2d2c109b8cd439734daa817408ea49d4e3cbab383794f0568254be
MD5 109b4d4c9cfdad00d25c1a875d2116e2
BLAKE2b-256 ae232486ada8b4d566f1af86e968e0158a3fdc77fcf2e6b013b467b9f77768ac

See more details on using hashes here.

Supported by

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