Skip to main content

pynissan

CI PyPI Python License: MIT

pynissan is an independently maintained async Python client for MyNISSAN connected vehicle services. It provides a typed API for vehicle telemetry, charging, climate, remote commands, account data, and connected-service features.

The client currently supports United States MyNISSAN accounts and includes Nissan Ariya telemetry and remote-control support.

Highlights

  • Fully async I/O built on aiohttp.
  • Typed, immutable response models and a py.typed marker.
  • Cached vehicle, battery, charging, climate, door, location, tire, and mileage data.
  • Charging, climate, lock, light, horn, engine, location, and status-refresh commands.
  • Climate and charge schedules, vehicle capabilities, alerts, maintenance, and history.
  • Automatic access-token refresh with a callback for persisting replacement tokens.
  • Static or refreshable request proof for protected service operations.
  • Read-only mode enabled by default for safe discovery and monitoring.
  • No dependency on Home Assistant.

Installation

python -m pip install pynissan

Python 3.12 or newer is required.

Quick start

The caller owns the aiohttp.ClientSession and decides how credentials and reusable tokens are stored.

from aiohttp import ClientSession

from pynissan import Country, NissanClient, Tokens


async def save_tokens(tokens: Tokens) -> None:
    """Persist replacement tokens in the application's secure storage."""


async def read_vehicle(email: str, password: str) -> None:
    async with ClientSession() as session:
        client = NissanClient(
            session,
            country=Country.US,
            token_listener=save_tokens,
        )
        await client.async_authenticate(email, password)

        vehicles = await client.async_get_vehicles()
        if not vehicles:
            return

        status = await client.async_get_vehicle_status(vehicles[0].vin)
        if status.battery is not None:
            print(status.battery.level)
            print(status.battery.is_charging)

Supply previously saved tokens to avoid signing in again:

client = NissanClient(
    session,
    country=Country.US,
    tokens=saved_tokens,
    token_listener=save_tokens,
)

The client refreshes expired tokens before a request and publishes the replacement token set through token_listener.

Protected operations accept a RequestProof value or an async RequestProofProvider. The provider is called with False for a current value and with True when the service rejects a stale value.

Read-only safety

NissanClient starts in read-only mode. Queries work normally, while methods that change vehicle or account state raise ReadOnlyError before any network request is sent.

from pynissan import Country, NissanClient

client = NissanClient(
    session,
    country=Country.US,
    tokens=saved_tokens,
    read_only=False,
)

Enable write access only for an explicit user action. Remote commands return a typed request that can be polled until Nissan reports a terminal status.

from pynissan import ClimateSettings, TemperatureUnit

request = await client.async_start_climate(
    vin,
    ClimateSettings(72, TemperatureUnit.FAHRENHEIT),
)
result = await client.async_wait_for_service_request(vin, request)

Charging state

Battery status distinguishes the cable and charging states and includes the server-provided remaining charge time.

battery = await client.async_get_vehicle_battery_status(vin)
if battery is not None:
    print(battery.level)
    print(battery.is_plugged_in)
    print(battery.is_charging)
    print(battery.remaining_charge_time)

Errors

All package exceptions inherit from NissanError:

  • AuthenticationError for sign-in and token-refresh failures;
  • NetworkError for connection and timeout failures;
  • ApiError for rejected HTTP requests;
  • GraphQLError for rejected GraphQL operations;
  • ResponseError for malformed responses;
  • ReadOnlyError for blocked state-changing operations.

Development

python -m pip install -e ".[test]"
python -m ruff check .
python -m ruff format --check .
python -m mypy
python -m pytest
python -m build

See the API guide and authentication guide for usage details. Development and release procedures are documented in CONTRIBUTING.md and docs/releasing.md. Security issues should follow SECURITY.md.

pynissan is an independent community project and is not affiliated with Nissan.

Download files

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

Source Distribution

pynissan-0.1.0.tar.gz (301.7 kB view details)

Uploaded Source

Built Distribution

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

pynissan-0.1.0-py3-none-any.whl (257.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynissan-0.1.0.tar.gz
  • Upload date:
  • Size: 301.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pynissan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4f179f5b3f14a8b553e93c00b8c5d9671f4f69a1fcbbcd78f22df0e4173f98d
MD5 49ce7af22b38f0d61f8e4693ed23553e
BLAKE2b-256 64c8798efa64418e706131ba0f341a8e31a2130a1635d43c35903393e9a92117

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on bvdcode/nissan-connect-sdk

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

File details

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

File metadata

  • Download URL: pynissan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 257.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pynissan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f07be4c33251833c34f2389b9b8f75748a811eacba037507bc3752ece5db32f
MD5 e0b8bbd3fa460037e78fbb0c3f539310
BLAKE2b-256 1b7ce83b5ad8fb1d045aa8cc35cfc530c4dd58960234ecec6042e8312ff21abd

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on bvdcode/nissan-connect-sdk

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