mothistory

package module
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 9 Imported by: 0

README

MOT History Go SDK

Test Release Go Report Card Go Reference License

The SDK provides convenient access to the MOT History API for applications written in the Go Programming Language.

Tests

Execute this command: go test -v

Integration Example

package main

import (
	"encoding/json"
	"fmt"
	"log"

	mothistory "github.com/0xnu/mothistory"
)

const (
	clientID     = "enter_your_client_id>"
	clientSecret = "enter_your_client_secret>"
	apiKey       = "enter_your_api_key"
)

func main() {
	config := mothistory.ClientConfig{
		ClientID:     clientID,
		ClientSecret: clientSecret,
		APIKey:       apiKey,
	}
	client := mothistory.NewClient(config, nil)

	// Get data by registration
	data, err := client.GetByRegistration("ML58FOU")
	if err != nil {
		log.Fatalf("failed to get data by registration: %v", err)
	}
	printJSON(data)

	// Get data by VIN
	data, err = client.GetByVIN("AISXXXTEST1239617")
	if err != nil {
		log.Fatalf("failed to get data by VIN: %v", err)
	}
	printJSON(data)

	// Get bulk download data
	data, err = client.GetBulkDownload()
	if err != nil {
		log.Fatalf("failed to get bulk download data: %v", err)
	}
	printJSON(data)

	// Renew credentials
	data, err = client.RenewCredentials(apiKey, "firstname.lastname@example.com")
	if err != nil {
		log.Fatalf("failed to renew credentials: %v", err)
	}
	printJSON(data)
}

func printJSON[T any](data *T) {
	prettyData, err := json.MarshalIndent(data, "", "  ")
    if err != nil {
			log.Fatalf("failed to marshal vehicle data: %v", err)
    }
    fmt.Println(string(prettyData))
}

Setting up a MOT History API

You can use this support form to request an API Key.

Using the MOT History API

You can read the API documentation to understand what's possible with the MOT History API. If you need further assistance, don't hesitate to contact the DVSA.

License

This project is licensed under the MIT License.

(c) 2023 - 2025 Finbarrs Oketunji.

The MOT History API Go SDK is Licensed under the Open Government Licence v3.0

Documentation

Index

Constants

View Source
const (
	TokenURL   = "https://login.microsoftonline.com/a455b827-244f-4c97-b5b4-ce5d13b4d00c/oauth2/v2.0/token"
	ScopeURL   = "https://tapi.dvsa.gov.uk/.default"
	RPSLimit   = 15
	BurstLimit = 10
	DailyQuota = 500000
)

Variables

View Source
var BaseURL string = "https://history.mot.api.gov.uk/v1/trade/vehicles"

Functions

This section is empty.

Types

type BulkDelta added in v1.0.7

type BulkDelta struct {
	Filename      string `json:"filename"`
	DownloadURL   string `json:"downloadUrl"`
	FileSize      int    `json:"fileSize"`
	FileCreatedOn string `json:"fileCreatedOn"`
}

type BulkDownloadResponse added in v1.0.7

type BulkDownloadResponse struct {
	Bulk  []BulkDelta `json:"bulk"`
	Delta []BulkDelta `json:"delta"`
}

Response for {baseURL}/[bulk-download]

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config ClientConfig, customHTTPClient *http.Client) *Client

func (*Client) GetBulkDownload added in v1.0.2

func (c *Client) GetBulkDownload() (*BulkDownloadResponse, error)

func (*Client) GetByRegistration

func (c *Client) GetByRegistration(registration string) (*VehicleDetailsResponse, error)

func (*Client) GetByVIN added in v1.0.2

func (c *Client) GetByVIN(vin string) (*VehicleDetailsResponse, error)

func (*Client) RenewCredentials added in v1.0.2

func (c *Client) RenewCredentials(apiKeyValue, email string) (*ClientSecretResponse, error)

type ClientConfig added in v1.0.2

type ClientConfig struct {
	ClientID     string
	ClientSecret string
	APIKey       string
}

type ClientSecretResponse added in v1.0.7

type ClientSecretResponse struct {
	ClientSecret string `json:"clientSecret"`
}

Response for v1/trade/[credentials]

type Defect added in v1.0.7

type Defect struct {
	Text         string `json:"text"`
	TypeOfDefect string `json:"type"`
	Dangerous    bool   `json:"dangerous"`
}

type MOTTest added in v1.0.7

type MOTTest struct {
	CompletedDate      string   `json:"completedDate"`
	TestResult         string   `json:"testResult"`
	ExpiryDate         string   `json:"expiryDate"`
	OdometerValue      string   `json:"odometerValue"`
	OdometerUnit       string   `json:"odometerUnit"`
	OdometerResultType string   `json:"odometerResultType"`
	MotTestNumber      string   `json:"motTestNumber"`
	DataSource         string   `json:"dataSource"`
	Location           string   `json:"location,omitempty"` // Optional field
	Defects            []Defect `json:"defects,omitempty"`  // Optional field
}

type VehicleDetailsResponse added in v1.0.7

type VehicleDetailsResponse struct {
	Registration         string    `json:"registration"`
	Make                 string    `json:"make"`
	FirstUsedDate        string    `json:"firstUsedDate"`
	FuelType             string    `json:"fuelType"`
	PrimaryColour        string    `json:"primaryColour"`
	RegistrationDate     string    `json:"registrationDate"`
	ManufactureDate      string    `json:"manufactureDate"`
	EngineSize           string    `json:"engineSize"`
	HasOutstandingRecall string    `json:"hasOutstandingRecall"`
	MotTests             []MOTTest `json:"motTests"`
}

Response for {baseURL}/[registration|vin]/<registration|vin>

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL