Skip to content

ClickMechanic/check_mot

Repository files navigation

CircleCI

Check MOT

Ruby implementation of UK Government MOT History API.

From the official API documentation:

The MOT history API gives authorised third-party organisations a way to access MOT test history information for vehicles.

The information includes:

  • MOT test date
  • MOT expiry date
  • test result
  • mileage reading
  • MOT test number
  • reasons for failure and advisory notices
  • first MOT due date for new vehicles
  • vehicle ID
  • vehicle registration date
  • vehicle manufacturing date
  • cylinder capacity of the engine

To access API you will need an API key that uniquely identifies the source of the request. DVSA will give you an API key if it approves your application.

Installation

Add this line to your application's Gemfile:

gem 'check_mot'

And then execute:

$ bundle

Or install it yourself as:

$ gem install check_mot

Usage

Require the dependency in your project:

require 'check_mot'

Configure your API key:

CheckMot.configure do |config|
  config.api_key = <your_api_key>
end

The gem uses Faraday under the hood. To optionally configure the HTTP adapter for Faraday, add the following to your CheckMot config:

config.http_adapter = <your_http_adapter>

To check a vehicle's MOT history using the registration number:

check_mot = CheckMot::Client.new
result = check_mot.by_vehicle_registration('AB01CDF')

result.registration # => "AB01CFD"
result.mot_tests.first.completed_date # => 2019-02-16 21:40:00
# etc

To request MOT tests completed on 15 August 2024 for page 1:

check_mot = CheckMot::Client.new
result = check_mot.by_date('20240815', page: 1)
result.first.mot_tests.first.test_result # => "PASSED"
# etc

Note: page is between 1 and 1440 inclusive. Dates that are over 5 weeks before the current date will produce a 400 error.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ClickMechanic/check_mot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the CheckMot project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.