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

akc4's avatar
Level 1

Most efficient way to get data from external API every 5 seconds?

What would be the most efficient way in Laravel to get data from an external API every ~5 seconds?

0 likes
5 replies
mabdullahsari's avatar

Calling that API every 5 seconds..?

Gotta give more context.

akc4's avatar
Level 1

Basically we are using a cloud-based telephony system and they offer an API. Now we need to make an API call to know if there are calls in queue.

just an API call and we get the json data needed.

akc4's avatar
Level 1

thanks will read all the links

Snapey's avatar

A lot of the spatie packages have been upgraded to require the latest versions of Laravel (7 or 8) and php 7.3+

If your project is older and in need of upgrade then you could try this other approach.

have multiple cronjobs that have sleep commands in them so that they fire at delayed intervals

* * * * * /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1
* * * * * sleep 10; /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1
* * * * * sleep 20; /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1
* * * * * sleep 30; /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1
* * * * * sleep 40; /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1
* * * * * sleep 50; /usr/bin/php /var/www/html/site/artisan collect-system-events >> /dev/null 2>&1

Please or to participate in this conversation.