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.
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/
-
MotClient
- new MotClient(apiKey)
-
instance
- .Timeout
-
.Lookup(page) ⇒
Array.<MotHistory>
-
.LookupDate(date, callback) ⇒
Array.<MotHistory>
-
.LookupDateTime(date, minute) ⇒
Array.<MotHistory>
-
.LookupVehicleId(vehicleId) ⇒
MotHistory
-
.LookupVrm(registration) ⇒
MotHistory
- static
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
Array.<MotHistory>
motClient.Lookup(page) ⇒ 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). |
Array.<MotHistory>
motClient.LookupDate(date, callback) ⇒ 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. |
Array.<MotHistory>
motClient.LookupDateTime(date, minute) ⇒ 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 |
MotHistory
motClient.LookupVehicleId(vehicleId) ⇒ 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. |
MotHistory
motClient.LookupVrm(registration) ⇒ 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.
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.
Kind: global variable