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

davidfravigar's avatar

Api consumtion and commands

Hi I am building an application that consumes and stores data from an external api that needs to be called every 15 minutes. I have created a command that calls the API and set it to run every 15 minutes.

The data returned is water level readings, that include a station and a measure, the returned data includes further url's to call to get the full information about the station or measure. Which I am doing if they do not exist in the database.

My command is starting to get a bit full with all the 'if ! station exists -> call the api and get the information -> save to the database.

The API also has some inconsistency with the data returned so checks need to be put in place.

What is the best course of implementing this correctly? Is a controller or a service the best way of doing this or is a basic class the best way.

If a basic class is the best way where would be the correct place to add this within the folder structure?

0 likes
2 replies

Please or to participate in this conversation.