Skip to content

dvsa/mot-public-api

Repository files navigation

MOT Public API

MOT Public API

This is the source code for an API which provides access to public MOT data.

It is written as a set of AWS Lambdas, intended to be connected to AWS API Gateway endpoints.

There is some unit test coverage, focussed on the most important code paths for frequently used endpoints.

This repository uses git-secrets to prevent secrets from being committed. Please ensure you have git-secrets installed on your machine: https://github.com/awslabs/git-secrets#installing-git-secrets

Building and running TAPI Locally

Prerequisite

Build

To build the application make sure you are in the root directory and then:

sam build

Run

To run the application locally make sure have a successful build whilst in the root directory and then:

sam local start-api --env-vars .env

This will start the application at http:://127.0.0.1:3000.

NOTE: If you would like to change the port number to for example 3001, use -p <port_number>.

sam local start-api --env-vars .env -p 3001

All paths and environments are listed in the template.yaml file. The values of the environment variables are listed in the .env file.

You can add/edit environment variables and paths as shown below:

template.yaml:

 Environment:
        Variables:
          MOTH_API_URL:
          MOTH_API_KEY:

.env:

{
  "Parameters": {
    "MOTH_API_URL": "https://api.search.com",
    "MOTH_API_KEY": "randomKey"
  }
}

You can edit/add endpoints:

template.yaml:

Events:
  VrmGet:
    Type: Api
    Properties:
      Path: /trade/vehicles/mot-tests
      Method: GET
  VrmPost:
    Type: Api
    Properties:
      Path: /trade/vehicles/annual-tests
      Method: GET

Each time you edit the code or template.yaml/.env you will need to build: sam build and run the application: sam local start-api --env-vars .env to see the changes.