The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

UK::Vehicle - Perl module to query the UK's Vehicle Enquiry Service API

SYNOPSIS

        use UK::Vehicle;
        my $tool  = new UK::Vehicle:(ves_api_key => '<your-api-key>');
        my $status = $tool->get('<vehicle-vrm>');
        $status->result;        # 1 for success, 0 for failure
        $status->message;       # 'success' or an error message
        $status->is_mot_valid();
        $status->is_vehicle_taxed();
        etc..

DESCRIPTION

This module helps you query the Vehicle Enquiry Service API provided by the UK's DVLA. In order to use it you must have an API key, which you can apply for here

You will likely need a decent reason to have an API key. It takes days to get one so you may want to apply now.

EXPORTS

None.

CONSTRUCTORS

new(ves_api_key => value)
new(ves_api_key => value, timeout => integer)

Create a new instance of this class, passing in the API key you wish to use. This argument is mandatory. Failure to set it upon creation will result in the method croaking.

Optionally also set the connect timeout in seconds. Default value is 10.

METHODS

get(string)
   my $status = $tool->get("ZZ99ABC");
   $status->result;  # 1 if success, 0 if not
   $status->message; # "success" if result was 1, error message if not
   $status->make; # "ROVER" etc.

Query the API for the publicly-available information about a vehicle. Returns a UK::Vehicle::Status, which has accessor methods for each of the properties returned by the VES API. For more information, see UK::Vehicle::Status.

Any spaces in the VRM you provide will be automatically removed. Lower case characters will be changed to upper case. If the VRM you provide contains weird characters, you will get 0 back and an appropriate message. Permitted characters are 0-9, a-z, A-Z.

BUGS AND REQUESTS

Please report to the GitHub repository.

AUTHOR

Ian Gibbs, <igibbs@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2022 by Ian Gibbs

This library is free software; you can redistribute it and/or modify it under the terms of the GNU GPL version 3.