0.0.4 • Published 4 years ago

@picturelink/mot-check v0.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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

Members

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.

ParamDescription
messageThe error message.
statusCodeThe HTTP status code returned by the MOT History API.
errorThe 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.

ParamDescription
apiKeyThe 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.
ParamDefaultDescription
page0The 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.
ParamDescription
dateThe date to lookup, any time part is discarded.
callbackAn 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.
ParamDefaultDescription
dateThe date to lookup, any time part is discarded.
minute1The 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.
ParamDescription
vehicleIdThe 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.
ParamDescription
registrationThe 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