Skip to main content

No project description provided

Project description

CEPiK Vehicle History Client

A Python client for retrieving vehicle history data from the Polish government's historiapojazdu.gov.pl service (CEPIK - Centralna Ewidencja Pojazdów i Kierowców).

Description

This repository contains a Python library that provides programmatic access to vehicle history information from the CEPiK database. The client handles session management, authentication, and data retrieval for both technical vehicle data and timeline/history information.

Features

  • Session Management: Automatic creation and management of authenticated sessions with moj.gov.pl
  • Vehicle Technical Data: Retrieve detailed technical specifications and current vehicle information
  • Timeline Data: Access complete vehicle history including ownership changes, registrations, and other events
  • Context Manager: Convenient authenticated_session() context manager for automatic session cleanup
  • Error Handling: Comprehensive error handling with custom exceptions
  • Session Cleanup: Proper session closure to prevent conflicts between executions

Requirements

  • Python 3.13+
  • PyPI

Installation

You can install the client using pip:

pip install cepik-vehicle-history-client

Usage

To use the client, you need three pieces of information about the vehicle:

  • Registration number (license plate)
  • VIN number
  • First registration date

Basic Example with Context Manager (Recommended)

from cepik_vehicle_history_client import VehicleHistoryClient, VehicleInfo

# Create vehicle info object
vehicle_info = VehicleInfo(
    registration_number="ABC12345",
    vin="1234567890ABCDEFG",
    first_registration_date="2020-01-15"
)

# Use context manager for automatic session management
client = VehicleHistoryClient()

try:
    with client.authenticated_session() as session:
        # Get vehicle technical data
        vehicle_data = session.get_vehicle_data(vehicle_info)
        print("Vehicle Data:", vehicle_data)
        
        # Get vehicle timeline/history
        timeline_data = session.get_timeline_data(vehicle_info)
        print("Timeline Data:", timeline_data)
        
except Exception as e:
    print(f"Error: {e}")

Manual Session Management

from cepik_vehicle_history_client import VehicleHistoryClient, VehicleInfo

# Create client and vehicle info
client = VehicleHistoryClient()
vehicle_info = VehicleInfo(
    registration_number="ABC12345",
    vin="1234567890ABCDEFG",
    first_registration_date="2020-01-15"
)

try:
    # Manual session creation and authentication
    client.create_session()
    client.authenticate_session()
    
    # Get vehicle data
    vehicle_data = client.get_vehicle_data(vehicle_info)
    print("Vehicle Data:", vehicle_data)
    
    # Get timeline data
    timeline_data = client.get_timeline_data(vehicle_info)
    print("Timeline Data:", timeline_data)
    
except Exception as e:
    print(f"Error: {e}")
finally:
    # Always close the session
    client.close_session()

API Reference

Classes

VehicleInfo

A dataclass containing vehicle identification information.

Attributes:

  • registration_number (str): Vehicle registration number (license plate)
  • vin (str): Vehicle Identification Number
  • first_registration_date (str): First registration date in YYYY-MM-DD format

VehicleHistoryClient

Main client class for accessing the CEPiK vehicle history service.

Methods

create_session() -> dict[str, str]

Creates a new session with the moj.gov.pl service and retrieves necessary cookies.

authenticate_session() -> tuple[dict[str, str], str]

Authenticates the session and returns updated cookies along with the session ID (NF_WID).

get_vehicle_data(vehicle_info: VehicleInfo) -> dict

Retrieves technical vehicle data including specifications, current status, and registration details.

get_timeline_data(vehicle_info: VehicleInfo) -> dict

Retrieves historical timeline data showing the vehicle's registration history, ownership changes, and other events.

close_session() -> None

Properly closes the session to free up resources on the server.

authenticated_session() (Context Manager)

Context manager that automatically handles session creation, authentication, and cleanup.

Exceptions

VehicleHistoryClientError

Base exception class for all client-related errors.

Data Format

The service returns data in Polish. Common fields include:

  • Vehicle Data: Technical specifications, current registration status, vehicle category
  • Timeline Data: Chronological history of registrations, ownership transfers, inspections

Important Notes

  • This client accesses a Polish government service - use it responsibly and in accordance with their terms of service and local law
  • The service may have rate limiting - avoid making excessive requests
  • Always ensure sessions are properly closed (use the context manager when possible)
  • Vehicle data requires accurate input - incorrect VIN, registration number, or date will result in no data

Legal and Ethical Use

This tool is intended for legitimate purposes, e.g.:

  • Vehicle purchase verification
  • Fleet management
  • Insurance verification

Please ensure you have proper authorization to access vehicle information and comply with Polish data protection laws.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is provided as-is for educational and legitimate business purposes. Users are responsible for ensuring compliance with applicable laws and terms of service.

Disclaimer

This is an unofficial client for the Polish government's vehicle history service. The authors are not affiliated with the Polish Government or the CEPiK system. Use at your own risk and ensure compliance with all applicable laws and regulations.

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

cepik_vehicle_history_client-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

cepik_vehicle_history_client-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for cepik_vehicle_history_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8cfd4dfc2374315bc684165bed781ec1c2caedc51951c7dabd0f55c247ef4e2
MD5 41e3b73586e7070e8dcdded9741ed45b
BLAKE2b-256 b2a2e294618b1a13ec6dde2af5defd654218ac34e5e636e0e1c6f8d1df95eb7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cepik_vehicle_history_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 093781c229ce9b0f350d5b5a3fce82170d91212a7f9a9ac1718368de03bd4f48
MD5 0f4624900c978735eb50ab981fd68238
BLAKE2b-256 ecd44db1653e988ff129c6b42b0c0ba4080f11d7202a2becdf79b7d4105de307

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