Hyundai/Kia Connect API

4.9.0 · active · verified Fri Apr 17

The `hyundai-kia-connect-api` library provides a Python interface to interact with Hyundai and Kia Connect (Bluelink/Uvo) services. It allows users to fetch vehicle status, send remote commands, and manage their connected car. The library is actively maintained with frequent releases (several times a month) to adapt to upstream API changes and add new features.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the `VehicleManager` with user credentials and region, then authenticates and fetches a list of vehicles and their latest status. Ensure environment variables `HMC_USERNAME`, `HMC_PASSWORD`, `HMC_PIN`, and `HMC_REGION` are set or replace placeholders directly in the script.

import os
from hyundai_kia_connect_api import VehicleManager, Regions

USERNAME = os.environ.get('HMC_USERNAME', 'your_username')
PASSWORD = os.environ.get('HMC_PASSWORD', 'your_password')
# Your 4-digit PIN, mandatory for some commands. Replace '1234' with your actual PIN.
PIN = os.environ.get('HMC_PIN', '1234')
# e.g., USA, EU, CA, AU, KR, IN. Replace 'USA' with your region.
REGION_CODE = os.environ.get('HMC_REGION', 'USA')

if USERNAME == 'your_username' or PASSWORD == 'your_password' or PIN == '1234':
    print("Please set HMC_USERNAME, HMC_PASSWORD, HMC_PIN, and HMC_REGION environment variables or update script placeholders.")
else:
    try:
        region = getattr(Regions, REGION_CODE.upper())
        manager = VehicleManager(
            username=USERNAME,
            password=PASSWORD,
            region=region,
            pin=PIN
        )
        
        print(f"Attempting to login for region: {REGION_CODE}")
        manager.check_and_update_token()
        print("Login successful. Fetching vehicles...")
        
        vehicles = manager.get_vehicles()
        if vehicles:
            print(f"Found {len(vehicles)} vehicle(s):")
            for vehicle_id, vehicle in vehicles.items():
                print(f"  Vehicle ID: {vehicle_id}, Name: {vehicle.name}")
                status = vehicle.get_latest_status()
                if status:
                    print(f"    Engine: {status.engineOn}, Doors: {status.doorOpen}, Lock: {status.doorLock}")
                else:
                    print("    Could not retrieve vehicle status (vehicle might be offline).")
        else:
            print("No vehicles found.")

    except Exception as e:
        print(f"An error occurred: {e}")
        print("Please ensure your username, password, PIN, and region are correct and your vehicle is connected.")

view raw JSON →