Skip to main content

Python SDK for DVLA Vehicle Enquiry Service API

Project description

DVLA Vehicle Enquiry Service Python SDK

GitHub Actions Workflow Status PyPI - Python Versions PyPI - Version

dvla_vehicle_enquiry_service is a Python SDK providing a simple interface for interacting with the DVLA (Driver and Vehicle Licensing Agency) Vehicle Enquiry Service API. It allows retrieval of detailed vehicle information based on the registration number, including tax status, MOT status, and more.

Installation

Install the package using pip:

pip install dvla_vehicle_enquiry_service

Usage

Initialisation

To use the VehicleEnquiryAPI class, you'll need an API key provided by the DVLA service. You can also specify the environment as either production or test (default is production).

from dvla_vehicle_enquiry_service import VehicleEnquiryAPI

api_key = "your_api_key"

# Initialise client using the default ('production') API
client = VehicleEnquiryAPI(api_key)

# Or initialise client using the test API
client = VehicleEnquiryAPI(api_key, environment="test")

Fetch Vehicle Details by Registration

To fetch vehicle details using its registration number:

import asyncio
from dvla_vehicle_enquiry_service import VehicleResponse, VehicleEnquiryError

async def get_vehicle_details():
    response = await api.get_vehicle("AA19MOT")
    mot_status = response.motStatus.value if response.motStatus else "Unknown"
    print(f"Vehicle Make: {response.make}, MOT Status: {mot_status}")

asyncio.run(get_vehicle_details())

If the request is successful, this example will print something such as: Vehicle Make: AUDI, MOT Status: Valid.

Error Handling

Errors are raised as VehicleEnquiryError exceptions. You can catch and handle these exceptions to access detailed error information.

try:
    response = await client.get_vehicle("ER19NFD")
except VehicleEnquiryError as e:
    print(f"Error {e.status}: {e.title} - {e.detail}")

Classes and Data Structures

Vehicle Class

  • VehicleResponse: Represents detailed information about a vehicle, including tax status, MOT status, make, model, and various other attributes.

Error Handling Classes

  • VehicleEnquiryError: Exception class that encapsulates error information, including status codes and error details.

Enum Classes

  • TaxStatus: Enumerates possible tax statuses of a vehicle (TAXED, UNTAXED, SORN, etc.).
  • MotStatus: Enumerates possible MOT statuses of a vehicle (VALID, NOT_VALID, NO_DETAILS_HELD, etc.).

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

dvla_vehicle_enquiry_service-1.0.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

dvla_vehicle_enquiry_service-1.0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file dvla_vehicle_enquiry_service-1.0.2.tar.gz.

File metadata

File hashes

Hashes for dvla_vehicle_enquiry_service-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d3549c829a665c202dbee8f218dced279e2d1c95b7fe47388e834dda4d97f08d
MD5 0f3280579dfb0fcdefa31cddaf850cac
BLAKE2b-256 47f7d6c91db9fda8be7ff31133d1b5a349e64d48b30c870a917e1d5b401853e0

See more details on using hashes here.

File details

Details for the file dvla_vehicle_enquiry_service-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dvla_vehicle_enquiry_service-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d49b4bd3f4232517e22454c223317c9364c32384df3025804b4371fdf57f4443
MD5 8a1b3eae4c9430672d826b13eba6760c
BLAKE2b-256 6657f50acddecbcaa6d2d015464d7e62c00970c420b39da866e1206fbd6682a8

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