This is a single restful API endpoint which should return Location points for a region on a map.
- Laravel 10
- PHP 8
Postman: https://www.postman.com/downloads/
- Clone the project
git clone git@github.com:blancessanchez/location-api.git-
Create database named locations.
-
Go to the project directory
cd location-api- Execute the necessary setup
php artisan migrate --path=database/migrations/api
php artisan db:seed
php artisan key:generate- Go to the .env file, change the following according to the credentials
DB_HOST=127.0.0.1
DB_DATABASE=locations
DB_USERNAME=root
DB_PASSWORD=- Go to the .env file, change the value for the api key
LOCATION_API_KEY=abcd- Start the server
php artisan serveMethod: GET
URL: http://127.0.0.1:8000/api/v1/locations
Parameters:
- latitude: required and numeric
- longitude: required and numeric
- radius: required and numeric
Add in the headers: X-API-Key: abcd
200 Success
[
{
"id": 1,
"name": "Toyota Taunton",
"latitude": "51.475603934275675",
"longitude": "-2.380716714519811",
"distance": 0
},
{
"id": 194,
"name": "Balnellan Road Car Park",
"latitude": "51.491571618028780",
"longitude": "-2.459211246136401",
"distance": 5.718032351573878
}
]422 Unprocessable Content
{
"message": "The latitude field is required.",
"errors": {
"latitude": [
"The latitude field is required."
]
}
}