Skip to main content

Unofficial Python client for the Leapmotor vehicle cloud API

Project description

leapmotor-api

Unofficial Python client for the Leapmotor vehicle cloud API.

Extracted from the leapmotor-ha Home Assistant integration to provide a reusable, framework-agnostic library.

Acknowledgments

Special thanks to Jakob Kern for the impressive reverse engineering work on the Leapmotor application and for generously sharing his work.

Installation

pip install leapmotor-api

Quick Start

from leapmotor_api import LeapmotorApiClient

client = LeapmotorApiClient(
    username="user@example.com",
    password="password",
    app_cert_path="/path/to/app_cert.pem",
    app_key_path="/path/to/app_key.pem",
    language="it-IT",  # default: en-GB
)

client.login()
vehicles = client.get_vehicle_list()

for vehicle in vehicles:
    print(f"{vehicle.vin} ({vehicle.car_type}) — {vehicle.nickname}")
    status = client.get_vehicle_status(vehicle)
    print(f"  Battery: {status.battery.soc}%")
    print(f"  Range: {status.battery.expected_mileage} km")
    print(f"  Odometer: {status.driving.total_mileage} km")

client.close()

Typed Models vs Raw Data

The library exposes two ways to access vehicle data:

Typed models (recommended)

get_vehicle_status() returns a VehicleStatus dataclass with typed sub-objects:

status = client.get_vehicle_status(vehicle)

# Battery & charging
status.battery.soc                  # int | None — state of charge %
status.battery.expected_mileage     # int | None — remaining range km
status.battery.is_charging          # bool | None
status.battery.charging_power_kw    # float | None
status.battery.dump_energy_kwh      # float | None — available energy in kWh

# Driving
status.driving.total_mileage        # int | None — odometer km
status.driving.speed                # int | None
status.driving.is_parked            # bool | None

# Location
status.location.latitude            # float | None
status.location.longitude           # float | None

# Climate
status.climate.ac_switch            # bool | None
status.climate.outdoor_temp         # int | None

# Doors & locks
status.doors.is_locked              # bool | None

# Windows
status.windows.left_front_window_percent   # int | None

# Tire pressure
status.tires.front_left_bar         # float | None — pressure in bar
status.tires.all_ok                 # bool | None — all pressures normal

# Connectivity
status.connectivity.bluetooth_state # bool | None

# Timestamps
status.collect_time                 # datetime | None

Raw API data

For forward-compatibility or debugging, use get_vehicle_raw_status():

raw = client.get_vehicle_raw_status(vehicle)
# Returns the full API JSON dict with signal codes, config, etc.
# raw["data"]["signal"]["1204"]  → battery SOC
# raw["data"]["config"]["3"]     → charging plan

The VehicleStatus object also retains the raw dict in status.raw for convenience.

Async Usage

from leapmotor_api import LeapmotorApiClient
from leapmotor_api.async_client import AsyncLeapmotorApiClient

sync_client = LeapmotorApiClient(
    username="user@example.com",
    password="password",
    app_cert_path="/path/to/app_cert.pem",
    app_key_path="/path/to/app_key.pem",
    language="it-IT",
)
client = AsyncLeapmotorApiClient(sync_client)

await client.login()
vehicles = await client.get_vehicle_list()
status = await client.get_vehicle_status(vehicles[0])
await client.close()

Remote Control

Remote actions require the vehicle PIN:

client = LeapmotorApiClient(
    username="user@example.com",
    password="password",
    app_cert_path="/path/to/app_cert.pem",
    app_key_path="/path/to/app_key.pem",
    operation_password="1234",
    language="de-DE",
)

client.login()
client.lock_vehicle("WLM...")
client.unlock_vehicle("WLM...")
client.open_trunk("WLM...")
client.close_trunk("WLM...")
client.find_vehicle("WLM...")
client.open_windows("WLM...")
client.close_windows("WLM...")
client.ac_switch("WLM...")
client.quick_cool("WLM...")
client.quick_heat("WLM...")
client.windshield_defrost("WLM...")
client.open_sunshade("WLM...")
client.close_sunshade("WLM...")
client.battery_preheat("WLM...")
client.set_charge_limit("WLM...", charge_limit_percent=80)
client.close()

License

MIT

Configuration

Parameter Type Default Description
username str Leapmotor account email
password str Leapmotor account password
app_cert_path str Path to app certificate PEM
app_key_path str Path to app private key PEM
operation_password str | None None Vehicle PIN (required for remote control)
language str "en-GB" API language (en-GB, it-IT, de-DE, fr-FR, …)
verify_ssl bool False Verify server TLS certificate
base_url str DEFAULT_BASE_URL API base URL
timeout int 30 HTTP timeout in seconds
device_id str | None None Custom device ID (auto-generated if omitted)

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

leapmotor_api-0.1.0.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

leapmotor_api-0.1.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file leapmotor_api-0.1.0.tar.gz.

File metadata

  • Download URL: leapmotor_api-0.1.0.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for leapmotor_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52c0b3811525edbf1f5ac71d384a8d29b6d976ca0f2d244b9e7114fecc9c7223
MD5 27c35ea5287eefec6c15c1488647c4b4
BLAKE2b-256 41addf90a76995b7e2b1dbacc6686260bc4b7a70d428debdf1d21b6499398edc

See more details on using hashes here.

Provenance

The following attestation bundles were made for leapmotor_api-0.1.0.tar.gz:

Publisher: publish.yml on markoceri/leapmotor-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file leapmotor_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: leapmotor_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for leapmotor_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 616a9c61854c33d4735b7a688d660605a5ba067a5d73b2645145b16dc3cab0ca
MD5 31499aef9061ba4185529d7204539b96
BLAKE2b-256 bda0c32542d4c0e61ddff6fb6f181a51f7a1103e20c5f4f846739368387952c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for leapmotor_api-0.1.0-py3-none-any.whl:

Publisher: publish.yml on markoceri/leapmotor-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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