Python SDK for DVSA MOT History API
Project description
DVSA MOT History Python SDK
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 import ErrorResponse
async def get_mot_history_by_registration():
response = await mot_history.get_vehicle_history_by_registration("AB12CDE")
if isinstance(response, ErrorResponse):
print(f"Error: {response.message}")
else:
print(f"Vehicle: {response.make} {response.model}")
for test in response.motTests:
print(f"Test Date: {test.completedDate}, Result: {test.testResult}")
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():
response = await mot_history.get_vehicle_history_by_vin("12345678901234567")
if isinstance(response, ErrorResponse):
print(f"Error: {response.message}")
else:
print(f"Vehicle: {response.make} {response.model}")
for test in response.motTests:
print(f"Test Date: {test.completedDate}, Result: {test.testResult}")
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():
response = await mot_history.get_bulk_download()
if isinstance(response, ErrorResponse):
print(f"Error: {response.message}")
else:
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}")
asyncio.run(download_bulk_mot_history())
Classes and Data Structures
MOT Test Classes
DVSAMotTestDVANIMotTestCVSMotTest
These classes represent the MOT test results from their respective agencies, containing details such as the test result, odometer readings, defects, and more.
Vehicle Response Classes
VehicleWithMotResponseNewRegVehicleResponse
These classes encapsulate vehicle information, including the make, model, registration details, and a list of MOT tests.
Error Handling
The ErrorResponse class handles errors returned by the API, providing details about the error, including the status code and message.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a pull request.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dvsa_mot_history-0.1.0.tar.gz.
File metadata
- Download URL: dvsa_mot_history-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f66196f1d4ae41357d94526a0f0cb028ad3045a70760e75b9767a9127ce1bbc
|
|
| MD5 |
e23c72229cb3f9581f8e8f52feccf829
|
|
| BLAKE2b-256 |
8946134a1af4b95c8533670aa4766e0e6e7d4be8886bfa0343ad03ae2e863654
|
File details
Details for the file dvsa_mot_history-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dvsa_mot_history-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbf63a855e8cec9d07ddcdd737b64d091808471264fe3d293f02e08dd6ab66e8
|
|
| MD5 |
97c157fd3152430ec6432c110db85b2b
|
|
| BLAKE2b-256 |
6220483075538c8ad9297105473bfab06d18f7eb99a7b133deba9d4403d545ce
|