I’m trying to set up my very first API to pull data from another application every 15 minutes.
The idea is to pull the data from their database and save it in the bubble dataset.
I was able to connect the API to the external source via teh API connector and got it initialised.
I then experimented with the backend flows, but was unable to get them to work.
Hi, can you be more specific on what’s not working
few guesses:
did you set your API call in the API connector to ‘Action’ so it is displayed in bw actions
did privacy rules prevent you from getting data required for the API call
Also:
have you considered the webhook solution instead of every 15min api calls? no way to trigger a call from this other application everytime a row is created in the table you want to sync?
Thanks for your reply.
I am pretty new to .bubble and especially the API side of things.
All I have on the other side is the API link—no webhook or option to push data from the outside to the app.
The API call was set up as data, as I thought this would be teh right thing if I just want to store the information in the dataset. I’ve changed it now.
I don’t know how to trigger the workflow every 15 minutes to pull the data in.
No privacy rules set up yet.
the API call you just setup in API connector (found by the name of your call)
whatever actions you need to create/modify entries in your own database (this can be another backend workflow with all your CRUD actions scheduled immediately)
and a schedule API workflow that triggers itself with a starting date:
current datetime +min: 15
you may also want to store the workflow scheduled id in case you want to stop the sync. In this case add a last action:
create a new DATATYPE (use a datatype to store the logs of scheduled workflows)
id = result of step 3 (schedule workflow action)
To initialize sync, add a button with an action that schedule the workflow for the first time.
you can then delete this button or setup a play/pause button that either:
schedule this sync workflow
cancel a scheduled workflow using the last entry in the datatype where you may have store the logs.
last thing: make sure of what is returned from the API to only sync new entries on their side and not add the entire database everytime the sync call run.
the API call return only new entry of the last 15 minutes, no worry
the API call return all the other app database, make sure you filter before create/edit your own database
i do not know if it is very good to be extracting data every 15 minutes, it seems unnecessary and dangerous, but anyway if you really need, go to the backends workflows, create a call, perform the actions you want and call again scheduling it in 15 minutes.
Great to see you taking on this challenge! Setting up scheduled backend workflows can be a bit tricky at first, but once you get the hang of it, it becomes really powerful.
Since you’ve already changed your API call to Action mode (as Eliot suggested), here’s what you need to do next. Go to your Backend Workflows section and create a new backend workflow. Inside that workflow, add an action to run your API call. Then, the key part is scheduling it: go back to the workflow you just created, click on the workflow settings, and you’ll see an option to Schedule on a recurring event. Set it to run every 15 minutes, and make sure the workflow is triggered automatically.
One more thing to watch out for: make sure your API response is being properly mapped to your database fields when creating or modifying things in Bubble. That’s usually where things get stuck.
If you’d like to discuss this more in detail, feel free to DM me directly.