Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JohnConnet's avatar

Create API and show data with Laravel from endpoint

So using Laravel i need to develop a way to give the user the option to find the best park for him, identify by latitude and longitude and get the ones in the proximity and the price of the park.

In order to get the list of parks, i need to acess a endpoint via API ex: http://api.parksandrecreation.com/data/parks using a POST. the apikey is parksandrecreationapi ; the parameters are lati, long and the apikey.

The integration sie needs to call the method: Search::getNearParks

parameter : $lati $long

So the expected output should be like: Park Name, Distance, ticket price

0 likes
7 replies
JohnConnet's avatar

how can i acess the endpoint and retrieve the data in order to present to the user

yoeriboven's avatar

Do you want us to write all of your code?

$response = Http::post('http://test.com/users', [
    'parksandrecreationapi' => 'api_key',
    'lati' => 'example_latitude',
    'long' => 'example_longitude',
]);

This should get you started.

tinfoilman's avatar

Your subject said to "create API" so I'm not clear what the scope of your project is.

Are you creating the API that holds the list of park data? Or are you creating a site that retrieves the data from another API that already exists?

JohnConnet's avatar

i' m not asking for the all code of course, just some lights to help...

JohnConnet's avatar

creating a site that retrieves the data from another API that already exists?

martinbean's avatar

i' m not asking for the all code of course, just some lights to help...

@johnconnet Then maybe try Googling “retrieve data from api using php”.

Please or to participate in this conversation.