MOT.NET 2.0.0

There is a newer version of this package available.
See the version list below for details.
Install-Package MOT.NET -Version 2.0.0
dotnet add package MOT.NET --version 2.0.0
<PackageReference Include="MOT.NET" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MOT.NET --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MOT.NET, 2.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MOT.NET as a Cake Addin
#addin nuget:?package=MOT.NET&version=2.0.0

// Install MOT.NET as a Cake Tool
#tool nuget:?package=MOT.NET&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Overview

MOT.NET is a .NET Core library which provides access to the DVSA's MOT history API.

As well as MOT tests, this API provides access to other vehicle data. These include registration date, cylinder capacity, fuel type and make and model.

Apply for API access

This API requires an API key. You may obtain an API key for your organisation by completing this application.

Setup

MotTestClient takes an API key as a SecureString. The example below shows converting a regular string to a SecureString to construct a MotTestClient:

// Example API key, replace with yours. Keep it secret!
var apikey = "foobar";

// Load the API key into a SecureString.
var securekey = new SecureString();
foreach(var character in apikey) {
    securekey.AppendChar(character);
}
securekey.MakeReadOnly();

// Initialise the MotTestClient.
IMotTestClient client = new MotTestClient(securekey);

Queries

Once initialised, the library may query the API in three different ways:

By vehicle:

Vehicles are queried by registration. Use the Registration method to specify a registration, and FetchAsync to fetch records:

// IAsyncEnumerable of Vehicles, allowing asynchronous streaming of results.
IAsyncEnumerable<Vehicle> vehicles = client
    .Registration("F1") // Set the registration to query.
    .FetchAsync(); // Fetch the vehicle from the API service.

// Asynchronously iterate reulsts.
await foreach(Vehicle vehicle in vehicles) {
    // Output vehicle make.
    Console.WriteLine(vehicle.Make);
}

By page:

Records are grouped in pages of 400-500 each. Use the Page method to specify a page, and FetchAsync to fetch records:

// Used after a previous query has been run, clears parameters.
client.Clear();

IAsyncEnumerable<Vehicle> vehicles = client
    .Page(0) // Set the page to query.
    .FetchAsync();

await foreach(Vehicle vehicle in vehicles) {
    // Output the vehicle models.
    Console.WriteLine(vehicle.Model);
}

This method is useful for downloading all records. Continue to download these pages from zero until exhaustion after ~50,000 pages (server will return status 404).

Note: The API is rate limited to 10 requests per second, make sure not to exceed this.

By date and page:

Records are queryable by date, with 1440 pages per day (1 page per minute).

Use the Date method to set the date parameter, the Page method to set the page parameter, and the FetchAsync method to fetch records:

client.Clear();

IAsyncEnumerable<Vehicle> vehicles = client
    .Date(DateTime.Today) // Set the page to query (to today).
    .Page(720) // Set the page to query (720 = noon).
    .FetchAsync();

await foreach(Vehicle vehicle in vehicles) {
    // Output the vehicle engine size.
    Console.WriteLine(vehicle.EngineSize;
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 246 2/5/2020
2.0.0 310 2/2/2020
1.2.0 334 1/25/2020