Categories
Uncategorized

Bubble App API Assistance

Bubble APIs: What, Why, and How 

Bubble provides a variety of tools to help you in your app development journey and all are specifically designed to not need code. Even the daunting prospect of implementing an Application Programming Interface (API) for your app can be accomplished in the Bubble framework with minimal advanced programming knowledge. 

This guide hopes to give you introductory Bubble App API assistance, and once you’re done with this resource Bubblehelpers has more in store to help you set up your Bubble App and its API. 

Why would I need an API? 

First though, why would you even need an API? An API allows your app to communicate with others. Through an API, other services and apps can activate workflows or access data from your app.  

Image sourced from Understanding API-Based Platforms: A Guide For Product Managers — Smashing Magazine 

This will allow your service and its users to become part of an integrated environment of other apps, making your service an indispensable utility to your users.  

It should be noted, though, that your app won’t always need its own API. Sometimes it can just leverage APIs or plugins from other programs to make use of their resources. For example, if you wanted to grab a collection of news stories from the New York Times or post a tweet on Twitter, you’re probably better off using Bubble’s API connector or plug-ins.  

On the other hand, if you want other apps to leverage your app’s workflows or data, these are exactly the use cases that the Bubble API is built for. 

What types of API does Bubble provide? 

Before you implement an API in Bubble, you’re going to need to pick which type will suit your needs. Bubble provides two APIs: the POST or Workflow API, and the GET or Data API.  

The first provides endpoints that execute or schedule workflows that can be triggered by another service, such as sending an email whenever a payment fails.  

The second allows other services to read or write data to your Bubble app’s database, such as when you want to allow developers on other projects to use your data.  

You can use either one or both, depending on your use cases.  

How do I activate a Workflow and/or Data API? 

Either way, their setup is similar. You can activate them by entering the API section of the Settings Tab in your Bubble App, then ticking the checkboxes you need. For the Data API you’ll also need to check the types of in-app data that you will expose to the outside world in the same menu. 

Once you’ve activated the APIs, you can find the URLs that they’re associated to in the same menu.  

The same menu also allows you to optionally set up authentication via OAuth or SAML. This will allow you to restrict certain API features to authenticated users. Said authentication can take various forms, depending on the developer, such as creating Sign Up/Log In workflows and redirects, creating API tokens with admin privileges on the app, session cookies, or not using authentication at all. 

From there, if you were working with the Data API, your job is complete. Bubble handles creating endpoints to access each type you exposed. Accessing the data exposed requires a certain syntax, and the responses the Data API will send follow their own pagination format whose processing will have to be handled by the receiver. 

How do I use the Workflow API? 

However, the Workflow API requires a bit more work on your part, as you will have to programmatically define the workflows that will be made available.  

To modify your Workflow API after you’ve set it up, go to your application page selector and enter the newly created “Backend Workflows” menu. This will give you a ‘page’ without a design tab, but with a workflow tab from which you can create the endpoints to which workflow requests will be directed and modify said workflows. 

When creating your endpoint, note that its name must be unique, and that its name must be made up of lowercase characters without any spaces.  

After you’ve created your workflow, you can also define parameters that the endpoint will accept along with their associated data types. Similarly, you can also define what data you will return to the requester, if you will return any data at all. 

The Workflow API interface also allows you to create and schedule scheduled workflows. Scheduled workflows allow the developer to schedule tasks that the application can execute once or periodically. These can be used to send periodic newsletters to users’ emails, or to terminate free trials after a certain amount of time. 

In case you need more assistance, feel more than free to check out the rest of Bubblehelpers’ blogs and resources for more Bubble App Support and API Assistance.