Forum Academy Marketplace Showcase Pricing Features

Saving data from API to database and having it call the API every 24 hours

Im pretty new to Bubble but I figured out how to bring in data from an API via the API connector. I am only able to pull in a certain amount of APIs a month from the site I got it from so im trying to figure out how to save the data from the API call directly to my database and have it automatically re-initialize the call every 12 or 24 hours and update the database that way? Im not very familiar with the backend workflows but any help is appreciated!

1 Like

When you initialize API connector call and set it to “data” and not “action”, Bubble will allow you to create a field using this DB Type from API Connector. So You can create an app with a field that will store all the data from API Connector.

Create a backend WF that will call this API and update the DB thing with the data from API.
In front end, create a page with a button that will schedule recurring Wf (depending of your plan) to run every day and update DB . If your plan doesn’t allow recurring WF so often, you can add a step in the backend WF to schedule itself 12 or 24hours later (Schedule backend workflow and not schedule recurring)

1 Like

There’s also remote chron job services that’ll ping your endpoints on a scheduled basis and you can just react to that.

1 Like

All of my API calls are already set to data. What I am trying to figure out is how to make the backend WF that will call the API and save it to the database first. If you have a screenshot of an example of a backend WF doing this that would be amazing.

In the screen shot, all Analyze Entitie are a Data type created from API Connector.
You can create a DB to store the information from API connector, create a field that is set to the type from API Connector.
Backend WF will Create a new thing in this DB only if Do a search for :count is 0. Set the field using Get data from API Connector.
Add another step to make change to a field Do a search for (the DB created):first item. Set the field using Get data from API Connector.

If needed Schedule this wf itself to update it X hours later. You can also use recurring WF if possible instead.

Thanks! So I was able to get it to save the data from the api call and go into the database in the correct fields. My data coming from the API might slightly change every day though so how can I have it either update the data if it has changed or when it runs the next day, delete the old data and just save the new data again ?

Just replace the data every time. Don’t look to update specific thing inside this field (it’s not really possible). So update the whole thing. (use = with Get data from API or Set list if this is a list)