Skip to main content

Python SDK for DVLA Vehicle Enquiry Service API

Project description

DVLA Vehicle Enquiry Service Python SDK

dvla_vehicle_enquiry_service is a Python SDK that provides 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 ErrorResponse, Vehicle

async def get_vehicle_details():
    response = await client.get_vehicle("ABC123")
    if isinstance(response, ErrorResponse):
        print(f"Error: {response.errors[0].title}")
    elif isinstance(response, Vehicle):
        print(f"Vehicle Make: {response.make}, MOT Status: {response.motStatus.value}")

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

The SDK returns an ErrorResponse object when an error occurs, containing a list of ErrorDetail objects with specific error information.

if isinstance(response, ErrorResponse):
    for error in response.errors:
        print(f"Error {error.status}: {error.title} - {error.detail}")

Classes and Data Structures

Vehicle Class

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

Error Handling Classes

  • ErrorResponse: Encapsulates the error response returned by the API.
  • ErrorDetail: Provides detailed information about individual errors.

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-0.1.0.tar.gz (5.1 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-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for dvla_vehicle_enquiry_service-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e943e853d161fbdf79f408e778f76db7b7ce4a3fffe4408c7b348407f14326bd
MD5 15fd68e7185d6e678d68a26fe8b5a4d9
BLAKE2b-256 71ecb2fa56dc410c27cbcfa31f7c8139440320ab45f0a6f1c4da42ce684310b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dvla_vehicle_enquiry_service-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7504510a4efefc68ea76c8cda31af90997814a6003ca1cd41bfa22a2ab739cfb
MD5 d1c874ddc621f3f7936973382c9fe7b9
BLAKE2b-256 447a698e1376df58158ecbc194b9a20c893c510a3c506b19dc985484ef95a3b4

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