MOT.NET 2.1.0

dotnet add package MOT.NET --version 2.1.0
NuGet\Install-Package MOT.NET -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MOT.NET" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MOT.NET --version 2.1.0
#r "nuget: MOT.NET, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.1.0

// Install MOT.NET as a Cake Tool
#tool nuget:?package=MOT.NET&version=2.1.0

MOT.NET

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 requires an API key, specify it in the constructor as follows:

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

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

If you prefer, you can provide the API key as a SecureString.

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;
}

Invalid Queries

The Page parameter may be used with the Date parameter. However, the Registration parameter may not be used with any other parameter.

Conversely, the Date parameter may not be used on its own and must be used with the Page parameter.

The library will throw an InvalidParametersException when parameters are combined in any way which the API will not accept.

Exceptions

Some API error responses are represented by exceptions to improve usability. These are thrown by FetchAsync.

These are NoRecordsFoundException; thrown when no records are found for the given parameters and InvalidApiKeyException; thrown when the specified API key is not accepted by the API service.

FetchAsync throws HttpResponseException for all other response codes (except 200).

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 543 2/5/2020
2.0.0 521 2/2/2020
1.2.0 606 1/25/2020