API Developer Guide
Overview
Welcome to the API Developer Guide. Please use the sandbox URL for testing purposes. When using the production version, ensure you have the production key and access. If you would like to opt into the program, please contact info@coachhire.com.
Authentication
To access the API, you must first log in using your credentials. The login URL is:
POST /api/auth/login
Request
URL: /api/auth/login
Method: POST
Content-Type: application/json
Body Parameters:
username
(string): Your username.password
(string): Your password.
Example Request
{
"username": "your_username",
"password": "your_password"
}
Successful Response:
{
"token": "your_token_here"
}
Example Response:
{
"token": "abc123xyz456"
}
Using the Token
Once you have the token, you need to include it in the header of your API requests. Use the following format:
Authorization: Bearer your_token_here
Example of an Authenticated Request
GET /api/your_endpoint
Host: api.yourdomain.com
Authorization: Bearer abc123xyz456
Make sure to replace abc123xyz456
with the actual token received from the login endpoint.
Requesting a Quote
To request a quote, you need to send a request to the /api/booking/quote
endpoint. This request requires authentication with the token, an AccessKey, and the following body parameters.
Request
URL: /api/booking/quote
Method: POST
Content-Type: application/json
Headers:
Authorization: Bearer your_token_here
AccessKey: your_secret_key_here
Body Parameters:
pickupDateTime
(string): The date and time for pickup (format: "YYYY-MM-DD HH: MM").pickupAddress
(string): The pickup address.pickupLat
(float): The latitude of the pickup location.pickupLng
(float): The longitude of the pickup location.extraDrop
(array): An array of additional drop-off locations. Each object should contain:Address
(string): The address of the extra drop.Lat
(float): The latitude of the extra drop location.Lng
(float): The longitude of the extra drop location.TravelType
(string): The type of journey (Outward Journey, Return Journey, Both Journeys).
dropoffAddress
(string): The dropoff address.dropoffLat
(float): The latitude of the dropoff location.dropoffLng
(float): The longitude of the dropoff location.NumberOfPassenger
(int): The number of passengers.LuggageType
(string): The type of luggage.VehicleType
(string): The type of vehicle.JourneyType
(string): The type of journey.returnTrip
(boolean): Indicates if it is a return trip.returnDateTime
(string): The date and time for the return trip (format: "YYYY-MM-DD HH:MM").passengerInfo
(object): An object containing passenger information.name
(string): The passenger's name.email
(string): The passenger's email address.phonenumber
(string): The passenger's phone number.
extRef
(string): The external reference number. (optional)notesCustomers
(string): Additional notes for the customer. (optional)
Example Request for Quote
{
"pickupDateTime": "2024-05-12 15:00",
"pickupAddress": "Tower of London",
"pickupLat": 51.5085985,
"pickupLng": -0.07633,
"extraDrop" : [
{
"Address" : "London Transport Museum",
"Lat": 51.5121233,
"Lng": -0.1212471;,
"TravelType": "Outward Journey"
},
{
"Address" : "Central London",
"Lat": 51.5001524,
"Lng": -0.1262362;,
"TravelType": "Return Journey"
},
{
"Address" : "Museum of London",
"Lat": 51.5177777,
"Lng": -0.0965835,
"TravelType": "Both Journeys"
}
],
"dropoffAddress": "London Bridge",
"dropoffLat": 51.5059213,
"dropoffLng": -0.0874807,
"NumberOfPassenger": 9,
"LuggageType": "No luggage.",
"VehicleType": "9-13 Seat Standard Mini Bus",
"JourneyType": "Business Travel",
"returnTrip": true,
"returnDateTime": "2024-05-15 07:00",
"passengerInfo" : {
"name" : "Yui Lau",
"email" : "xxx@email.com",
"phonenumber" : "xxxxxxxxxx"
},
"extRef" : "123456",
"notesCustomers" : "customer notes"
}
Example Response for Quote
{
"quote_id": 1003787,
"status": 1,
"message": "Quote created",
"error": false,
"priceInfo" : {
"vehiclePrice": 1530.66,
"vehiclePriceTotal": 1684,
"vat": "10.00",
"status": 1,
"message": "journey price found"
}
}
Get Available Vehicle Types
To find out what types of vehicles are available based on the number of passengers, use the following endpoint:
Request
URL: /api/booking/availableVehicleTypes/:NumberOfPassenger
Method: GET
Content-Type: application/json
Headers:
Authorization: Bearer your_token_here
AccessKey: your_secret_key_here
Path Variables:
NumberOfPassenger
(string): The number of passengers.
Example Request
GET /api/booking/availableVehicleTypes/2
Example Response:
{
"count": 1,
"result":[
{
"car_id": "2",
"car_name": "9-13 Seat Standard Mini Bus",
"short_des": "**Typically Toyota Hiace or similar.",
"long_des":"* CD Audio System* Seatbelts* Air Conditioning* Window Tint* PA",
"bagList": [
{
"bag_id": "1",
"bag_des": "No luggage."
"bag_size": "0.00"
},
{
"bag_id": "2",
"bag_des": "1.00"
},
{
"bag_id": "3",
"bag_des": "2.00"
},
{
"bag_id": "4",
"bag_des": "3.00"
}
]
}
]
}
User extension number
To find out what user extension number based on customer phone number, use the following endpoint:
Request
URL: /api/customer/extension/:phoneNumber
Method: GET
Content-Type: application/json
Headers:
Authorization: Bearer your_token_here
AccessKey: your_secret_key_here
Path Variables:
phoneNumber
(string): The number of phone number.
Example Request
GET /api/customer/extension/xxxxxxxxxx
Example Response:
{
"name": "Yui Lau",
"ext_number": "xxxx"
}
Error Messages
- Missing required field: Ensure that all required fields are included in your request.
- Vehicle type is required: Please check our booking form for the available vehicle types and include the appropriate type in your request.
- Luggage type is required: Please check our booking form for the available luggage types and include the appropriate type in your request.
- Vehicle size not matching with your journey info: Ensure that the selected vehicle size is appropriate for the number of passengers and luggage specified in your request.