MENU navbar-image

Introduction

This documentation aims to provide all the information you need to work with our API.

Authenticating requests

To authenticate requests, include a X-Authorization header with the value "Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

The API token is generated in the server console.

Endpoints

Checking user registration.

requires authentication

Example request:
curl --request POST \
    "http://localhost/api/user/login" \
    --header "X-Authorization: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"email\": \"cdickinson@example.net\"
}"
const url = new URL(
    "http://localhost/api/user/login"
);

const headers = {
    "X-Authorization": "Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "cdickinson@example.net"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200, User is registered):


{
    "name": "123",
    "email": "test123@test.test",
    "requestsToWeek": 3,
    "HTMLResponse": {
        "StatusCode": 200,
        "Description": "Request OK"
    }
}
 

Example response (203, User not found!):


{
    "status": "error",
    "message": "User not found!"
}
 

Request      

POST api/user/login

Headers

X-Authorization      

Example: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

email   string   

Must be a valid email address. Must not be greater than 100 characters. Example: cdickinson@example.net

Response

Response Fields

name   string   

Username.

email   string   

Email.

RequestsToWeek      

Number of requests per week.

User registration.

requires authentication

Example request:
curl --request POST \
    "http://localhost/api/user/registration" \
    --header "X-Authorization: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"umjlqrqpxyqrsfnbt\",
    \"email\": \"luettgen.woodrow@example.net\",
    \"phone\": \"qyuzpdbsmrrq\",
    \"legalNotice\": false
}"
const url = new URL(
    "http://localhost/api/user/registration"
);

const headers = {
    "X-Authorization": "Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "umjlqrqpxyqrsfnbt",
    "email": "luettgen.woodrow@example.net",
    "phone": "qyuzpdbsmrrq",
    "legalNotice": false
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200, User is registered):


{
    "name": "123",
    "email": "test123@test.test",
    "requestsToWeek": 3,
    "HTMLResponse": {
        "StatusCode": 200,
        "Description": "Request OK"
    }
}
 

Example response (208, The user already exists.):


{
    "status": "error",
    "message": "The user already exists."
}
 

Request      

POST api/user/registration

Headers

X-Authorization      

Example: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

name   string   

Must not be greater than 50 characters. Example: umjlqrqpxyqrsfnbt

email   string   

Must be a valid email address. Must not be greater than 100 characters. Example: luettgen.woodrow@example.net

phone   string  optional  

Must not be greater than 20 characters. Example: qyuzpdbsmrrq

legalNotice   boolean   

Example: false

Response

Response Fields

name   string   

Username.

email   string   

Email.

RequestsToWeek      

Number of requests per week.

List of cities/postal codes by the first 3 characters.

requires authentication

After the user enters 3 characters, you can query the server for all options that have these characters in them.

Example request:
curl --request POST \
    "http://localhost/api/stations/searchList" \
    --header "X-Authorization: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"search\": \"lon\"
}"
const url = new URL(
    "http://localhost/api/stations/searchList"
);

const headers = {
    "X-Authorization": "Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "lon"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200, List):


{
    "list": [
        "LONDON",
        "LONDONDERRY",
        "ELLON",
        "LONGNIDDRY",
        "LONGFIELD",
        "ISLE OF COLONSAY"
    ],
    "HTMLResponse": {
        "StatusCode": 200,
        "Description": "Request OK"
    }
}
 

Request      

POST api/stations/searchList

Headers

X-Authorization      

Example: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

search   string  optional  

Must be at least 3 characters. Must not be greater than 20 characters. Example: lon

Response

Response Fields

list   string[]   

List of allowable values.

requires authentication

Outputs all stations that match the parameters.

Example request:
curl --request POST \
    "http://localhost/api/stations/search" \
    --header "X-Authorization: Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"search\": \"lon\",
    \"email\": \"kavon38@example.com\",
    \"radius\": \"10\"
}"
const url = new URL(
    "http://localhost/api/stations/search"
);

const headers = {
    "X-Authorization": "Rg2x82VqJsi7chf1h6nPEO3Seht0CN6oHyDjWtr2vizCHDArTWn4Q232kMth17wv",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "lon",
    "email": "kavon38@example.com",
    "radius": "10"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200, User):


{
    "User": {
        "name": "123",
        "email": "test123@test.test",
        "RequestsToWeek": 5
    },
    "Stations": [
        {
            "id": 5,
            "fuelBrandName": "ESSO",
            "siteName": "MFG WARLINGHAM",
            "address": "LIMPSFIELD ROAD",
            "suburb": "",
            "town": "WARLINGHAM",
            "county": "SURREY",
            "postcode": "CR6 9LA",
            "petrol": {
                "id": 20255,
                "station_id": 5,
                "fuel_id": 2,
                "priceDate": "2023-01-02",
                "lowestPrice": 1539,
                "lowestPriceTime": "11:37:00",
                "highestPrice": 1539,
                "highestPriceTime": "11:37:00",
                "lastPrice": 1539,
                "lastPriceTime": "11:37:00",
                "modalPrice": 1539,
                "averagePrice": 1539,
                "created_at": "2023-01-04T20:45:47.000000Z",
                "updated_at": "2023-01-04T20:45:47.000000Z"
            },
            "disel": {
                "id": 20256,
                "station_id": 5,
                "fuel_id": 6,
                "priceDate": "2023-01-03",
                "lowestPrice": 1779,
                "lowestPriceTime": "07:38:00",
                "highestPrice": 1779,
                "highestPriceTime": "07:38:00",
                "lastPrice": 1779,
                "lastPriceTime": "07:38:00",
                "modalPrice": 1779,
                "averagePrice": 1779,
                "created_at": "2023-01-04T20:45:47.000000Z",
                "updated_at": "2023-01-04T20:45:47.000000Z"
            },
            "location": {
                "type": "Point",
                "coordinates": [
                    51.481176,
                    -0.09462
                ]
            }
        }
    ],
    "HTMLResponse": {
        "StatusCode": 200,
        "Description": "Request OK"
    }
}
 

Example response (203, User not found!):


{
    "status": "error",
    "message": "User not found!"
}
 

Example response (403, Request limit exceeded!):


{
    "status": "error",
    "message": "Request limit exceeded!"
}
 

Response

Response Fields

User   string[]   

Array of user data.

Stations   string[]   

Array of station data and fuel prices.