Skip to main content

DVSA MOT History Python SDK

GitHub Actions Workflow Status PyPI - Python Versions PyPI - Version

dvsa_mot_history is a Python SDK that provides a simple interface for interacting with the DVSA MOT History API, allowing retrieval of MOT history, test results, and bulk downloads for vehicles registered with DVSA, DVA Northern Ireland, or the Commercial Vehicle Service.

Features

  • Retrieve Vehicle MOT History by Registration: Fetch detailed MOT history using a vehicle's registration number.
  • Retrieve Vehicle MOT History by VIN: Fetch detailed MOT history using a vehicle's VIN.
  • Bulk Download of MOT History Data: Retrieve bulk MOT history data files for further processing.

Installation

Install the package using pip:

pip install dvsa_mot_history

Usage

Initialisation

To use the MOTHistory class, you'll need the client_id, client_secret, tenant_id, and api_key credentials provided by the DVSA API service.

from dvsa_mot_history import MOTHistory

mot_history = MOTHistory(
    client_id="your-client-id",
    client_secret="your-client-secret",
    tenant_id="your-tenant-id",
    api_key="your-api-key"
)

Fetch MOT History by Registration

To fetch MOT history for a vehicle using its registration number:

import asyncio
from dvsa_mot_history.errors import VehicleHistoryError

async def get_mot_history_by_registration():
    try:
        response = await mot_history.get_vehicle_history_by_registration("AB12CDE")
        print(f"Vehicle: {response.make} {response.model}")
        for test in response.motTests:
            print(f"Test Date: {test.completedDate}, Result: {test.testResult}")
    except VehicleHistoryError as e:
        print(f"Error: {e.message}")

asyncio.run(get_mot_history_by_registration())

Fetch MOT History by VIN

To fetch MOT history for a vehicle using its VIN:

async def get_mot_history_by_vin():
    try:
        response = await mot_history.get_vehicle_history_by_vin("12345678901234567")
        print(f"Vehicle: {response.make} {response.model}")
        for test in response.motTests:
            print(f"Test Date: {test.completedDate}, Result: {test.testResult}")
    except VehicleHistoryError as e:
        print(f"Error: {e.message}")

asyncio.run(get_mot_history_by_vin())

Bulk Download of MOT History Data

To download bulk MOT history data:

async def download_bulk_mot_history():
    try:
        response = await mot_history.get_bulk_download()
        for file in response.bulk:
            print(f"Bulk File: {file.filename}, URL: {file.downloadUrl}")
        for file in response.delta:
            print(f"Delta File: {file.filename}, URL: {file.downloadUrl}")
    except VehicleHistoryError as e:
        print(f"Error: {e.message}")

asyncio.run(download_bulk_mot_history())

Classes and Data Structures

MOT Test Classes

  • DVSAMotTest
  • DVANIMotTest
  • CVSMotTest

These classes represent the MOT test results from their respective agencies, containing details such as the test result, odometer readings, defects, and more.

MotTestType: This is a type alias that encompasses the possible MOT test classes detailed above.

Vehicle Response Classes

  • VehicleWithMotResponse
  • NewRegVehicleResponse

These classes encapsulate vehicle information, including the make, model, registration details, and a list of MOT tests.

VehicleResponseType: This is a type alias that encompasses the possible vehicle response classes detailed above.

Error Handling

The VehicleHistoryError exception class handles errors returned by the API, providing details about the error, including the status code and message. The previous ErrorResponse class has been removed, and error handling is now done through exceptions.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

Metadata

Release files for dvsa-mot-history 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dvsa-mot-history 1.0.4
File Size Uploaded Provenance Actions
dvsa_mot_history-1.0.4.tar.gz 8.3 kB Without provenance Details for dvsa_mot_history-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dvsa-mot-history 1.0.4
File Interpreter ABI Platform Actions
dvsa_mot_history-1.0.4-py3-none-any.whl Python 3 none any Details for dvsa_mot_history-1.0.4-py3-none-any.whl

Total release size: 17.6 kB

Release files / dvsa_mot_history-1.0.4.tar.gz

Download URL dvsa_mot_history-1.0.4.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
47129788b9a3d89c1405d326c1f74674cafd2b9d0242a3f0dd78320936be7256
BLAKE2b-256 checksum
How to use checksums
0720afcaf52f95800d9ec1d041d3ba9d5e56ece678ab3eb42ed4dd9337184c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / dvsa_mot_history-1.0.4-py3-none-any.whl

Download URL dvsa_mot_history-1.0.4-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e7c700a24ee8b94f49ae8871ae34cf11fb2ae1f2708d778d0b18c98b96ffe52
BLAKE2b-256 checksum
How to use checksums
9e5925b12220beb12e2b9e0b15bfac78b6e1b6a44bc38c24eac77d662ec36ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Security for dvsa-mot-history 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page