@picturelink/mot-check
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

dvla-mot-check-js

A simple javascript library for accessing the DVLA MOT Check API.

How it works

Before getting started you will need to apply for an API key to access the service.

Installation

To install dvla-mot-check-js:

npm install @picturelink/mot-check
# or
yarn add @picturelink/mot-check

Using the client

Once installed, it's simply a case of creating an instance of the MotClient and calling methods on it:

import { MotClient } from "@picturelink/mot-check";

const client = new MotClient("YOUR API KEY");
client.Timeout = 30; // In case 15 seconds isn't enough...

client.LookupVrm(vrm)
  .then((result) => {
    console.log(result);
  });
  
// or using async
const result = await client.LookupVrm(vrm);

Reference

Classes

ApiError

Represents an error thrown when the MOT History API returns an invalid response.

MotClient

A simple client used to access the DVLA MOT History API.

Members

FailureReasonType

The possible values for the reason-for-failure type field.

FuelType

The possible values for the fuel type field.

OdometerResultType

The possible values for the odometer result type field.

OdometerUnit

The possible values for the odometer unit field.

TestResult

The possible values for the test result field.

ApiError

Represents an error thrown when the MOT History API returns an invalid response.

Kind: global class

new ApiError(message, statusCode, error)

Creates an instance of the APIError class.

Param Description
message The error message.
statusCode The HTTP status code returned by the MOT History API.
error The error object returned by the MOT History API.

MotClient

A simple client used to access the DVLA MOT History API.

Kind: global class See: https://dvsa.github.io/mot-history-api-documentation/

new MotClient(apiKey)

Creates an instance of the MotClient class.

Param Description
apiKey The API key used to access the DVLA MOT History API.

motClient.Timeout

The number of seconds after which a request times out. Defaults to 15 seconds.

Kind: instance property of MotClient

motClient.Lookup(page) ⇒ Array.<MotHistory>

Returns a promise containing a list of MOT history objects.

Kind: instance method of MotClient Returns: Array.<MotHistory> - An array of MOT history records. Throws:

  • ApiError When the MOT History API returns an error response.
Param Default Description
page 0 The page number to retrieve (0 based).

motClient.LookupDate(date, callback) ⇒ Array.<MotHistory>

Returns a promise containing a list of MOT history objects for the specified date.

Kind: instance method of MotClient Returns: Array.<MotHistory> - An array of MOT history records. Throws:

  • ApiError When the MOT History API returns an error response.
Param Description
date The date to lookup, any time part is discarded.
callback An optional callback function that reports the progress.

motClient.LookupDateTime(date, minute) ⇒ Array.<MotHistory>

Returns a promise containing a list of MOT history objects for the specified date.

Kind: instance method of MotClient Returns: Array.<MotHistory> - An array of MOT history records. Throws:

  • ApiError When the MOT History API returns an error response.
Param Default Description
date The date to lookup, any time part is discarded.
minute 1 The minute of the day, where 1 = 00:01, 330 = 05:30 1440 = 00:00

motClient.LookupVehicleId(vehicleId) ⇒ MotHistory

Returns a promise containing an MOT history object for the specified vehicle.

Kind: instance method of MotClient Returns: MotHistory - The MOT history record for the vehicle or null if not found. Throws:

  • ApiError When the MOT History API returns an error response.
Param Description
vehicleId The unique DVLA ID of the vehicle.

motClient.LookupVrm(registration) ⇒ MotHistory

Returns a promise containing an MOT history object for the specified vehicle.

Kind: instance method of MotClient Returns: MotHistory - The MOT history record for the vehicle or null if not found. Throws:

  • ApiError When the MOT History API returns an error response.
Param Description
registration The vehicle registration mark.

MotClient.IsBeta

A flag indicating whether this client consumes a beta version of the MOT History API.

Kind: static property of MotClient

MotClient.Version

The version of the MOT History API that this client has been written for.

Kind: static property of MotClient

FailureReasonType

The possible values for the reason-for-failure type field.

Kind: global variable

FuelType

The possible values for the fuel type field.

Kind: global variable

OdometerResultType

The possible values for the odometer result type field.

Kind: global variable

OdometerUnit

The possible values for the odometer unit field.

Kind: global variable

TestResult

The possible values for the test result field.

Kind: global variable

Readme

Keywords

Package Sidebar

Install

npm i @picturelink/mot-check

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

33 kB

Total Files

30

Last publish

Collaborators

  • john.bayly