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

OneSeventeen's avatar

Public Site based on external API - direct or sync with local DB?

At work we have a system that has a decent API and even has a Laravel package maintained by a community member. I've used it to make a few public facing tools like a check-in system and barcode printing system, and the only Laravel schema is for user accounts.

Overall it is super quick and works fine, but I'm also missing out on all of the awesomeness of Eloquent.

Most of the data I'm reading from the database only needs to be refreshed once or twice a day, so I'm considering writing a sync tool to pull all the data I need and insert it into a relational database, but then when someone needs to write to the database I'd hit the API to submit the data, then re-pull the related data into my project.

This would reduce the number of external API hits my system needs to make, and might lighten the load of the main application, but it also adds a little bit of complexity.

Have any of you written an application primarily for interacting with a 3rd party API? If so, do you sync data and interact locally, or do you make each page load hit the external API?

0 likes
3 replies
Sinnbeck's avatar

I have a somewhat similar problem that I solve in this way. For me it is a local sql database used by some old systems. (I am not allowed to change the database it any way). The data is used to run statistics calculations.

The data is really poorly structured and loading it is a big hazzle (and slow). So I have a scheduled job that syncs some of the data to another database where it is indexed properly.

This makes working with the data much easier and a lot faster.

1 like
jove's avatar
jove
Best Answer
Level 7

When I get nothing from just displaying old data I don't keep a local sync and only get it when I need it (if there is a lot of traffic on my system I sync it to be nice with the third party).

If I can live with old data without updating external data I keep a sync that updates when you try to update something and when you view something + a scheduled sync.

1 like
OneSeventeen's avatar

Thanks, it is good to hear your perspectives and experiences. I feel more comfortable about syncing data knowing others do the same.

1 like

Please or to participate in this conversation.