Skip to content

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

License

Notifications You must be signed in to change notification settings

0xnu/mothistory

Repository files navigation

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.

Copyright

(c) 2023 - 2024 Finbarrs Oketunji.

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