[New Feature] Data API now supports writing as well as reading data

Bubble’s Data API lets you publish your applications’ data via API in a single click, instantly giving you a rich interface with all the power of Bubble’s database, search engine, and privacy rules.

While the Data API lets connected services read data, the only option we offered to write data was the Workflow API, which lets you run workflows via the API. The Workflow API is very powerful; you can invoke all of Bubble’s functionality, including modifying data, sending emails, processing payments, and connecting to other services. But the downside is that it requires creating a new workflow for each action that you want to expose to the user. This gives you a lot of control, but it can be time consuming if you just want to allow general access to modify data.

We have now bridged that gap by enabling writing as well as reading via the Data API. You can now:

  • Modify a thing
  • Delete a thing
  • Create a new thing
  • Bulk upload a bunch of things

All without building a single workflow!

Access to the write capabilities are governed via new permissions available on the Privacy Tab: Modify via API, Delete via API, and Create via API. These permissions are off by default, but you can grant them to allow your users to start writing as well as reading data. (If you are accessing the API via a token with administrative access, you do have these permission by default). The new permissions will only be visible if a data type is exposed via the Data api, which you can do on the Settings -> API tab.

Full documentation of the new features is available in the updated reference section for the Data API: https://bubble.io/reference#API.get_api

17 Likes

Awesome! This is a big deal for anyone with data intensive apps as it’ll allow all of us to load large sets into Bubble quickly. This opens up a whole new set of opportunities related to real-time algorithms, personalization based on data from 3rd parties, etc.

I tried configuring bulk upload and getting below error for all entries (repeating)

{“status”:“error”,“message”:“Could not parse as JSON: ------WebKitFormBoundaryTrptJoBbfcNDkg8z\r”}
{“status”:“error”,“message”:“Could not parse as JSON: Content-Disposition: form-data; name=”{%22Name%22"\r"}
{“status”:“error”,“message”:“Could not parse as JSON: Customer, “Mobile”: 9000000998}\r”}

The api url used

https://{app_name}.bubbleapps.io/api/1.1/obj/{type_name}/bulk

{app_name} replaced by actual app name and type name in small letters.

In header I have used content type as plain text.

Can you please help me with this.

1 Like

After changing the text to raw - postmaster I am getting below error

{“status”:“error”,“message”:“Could not parse as JSON: {“Name”:Customer1, “Mobile”: 9098789098}”}
{“status”:“error”,“message”:“Could not parse as JSON: {“Name”:Customer2, “Mobile”: 9098789097}”}

Thanks!

Would it make sense to replace Schedule API workflow on a list with a bulk create thing via API? Will it be faster or more resource friendly? Or would this make more sense for external data coming into Bubble?

1 Like

Hello there,

For non technical person, would you mind to elaborate a situation where an app can really get improved for the use of this?

Thanks man.

Have a good day.

Bests.

2 Likes

Is there any way to use “add to list”, “remove from list”, “set list”, “clear list” commands when “Modifying a Thing” with the new API or do we have to use Workflows?

1 Like

@raghavs.inc it looks like the issue is that you don’t have quotes around Customer1 and Customer2. Each individual line in the file needs to be valid JSON. For more information on JSON and examples, see https://en.m.wikipedia.org/wiki/JSON

@vincent56 if you’re trying to get external data into Bubble, this is probably the easiest and fastest approach. But it can’t be used from inside bubble and it is not as flexible as schedule API workflow on a list, so it isn’t a general replacement for it.

@cem you can effectively do set list and clear list by setting a list field to an array or to null. There isn’t a way of using this to add or remove a single item from a list without replacing the entire list (though we can consider adding that in the future if that’s a popular request).

Sure. One way we plan to use it, for example, is to personalize the each user’s feed and weekly digest. We’ll do so by sending all of the upcoming events in our system along with data about each user’s preferences to an algorithm and have it send back a personalized list of events for each user. This wasn’t particularly viable with running a workflow on a list since that approach was too slow when loading large amounts of data back into bubble.

1 Like

Hey @josh

I am interested in this new feature as I was trying to build a product earlier that will allow users to call on data stored in bubble.

The only downside or lack of is the option to have the users generate there own APIs keys to use.

You mentioned OAuth 2 are there any plans to allow us to generate none admin API keys dynamically through a workflow?

You can already do this with a signup/login workflow. The token that is returned from such a workflow is essentially a key.

– Create Sign up/Login API workflows. This is useful for building an alternative front-end to the Bubble app, such as a native app that you developed. When an API workflow contains a sign up or login action, then a user ID, token, and expiration, expressed in seconds, are returned with the response of the call. Subsequent calls to the app’s API, with a header Authorization: Bearer API_TOKEN, runs all calls and workflows in the context of the user associated with the token. This user will be the ‘Current user,’ who you can access with actions. Privacy rules will apply to this user as they would if the user was logging in the Bubble app and using it in their own browser. This token should be kept safe.

1 Like

Hey @emmanuel

I tried that. The key generated has a limited time attached to it. Is there another possibility to have an unrestricted time interval

If you check the box at the login action level (Stay logged in https://bubble.io/reference#Actions.LogIn.stay_logged_in) the key is valid for a year.

2 Likes

Congrats on this development, will save loads of time getting APIs setup and lower those barriers even more!

Just wondering about the new endpoints being included in the Swagger/OpenAPI spec for a project as I’m not seeing them just now? Apologies if I’m missing a step I need to take.

We just added the calls to the swagger endpoint.

2 Likes

Ah great, thanks for the update. I’m updating our tutorial on connecting Bubble to Dropsource - it’ll be even shorter now… :tada:

1 Like

@josh - Just to confirm, because based on your response to @vincent56, I’m trying to understand if your new bulk loader can be finagled to replace schedule a workflow on a list that hits another endpoint to store the multi-row response from the POST call one row at a time.

One idea, if this isn’t a replacement for scheduling a workflow on a list is to instead, return the response via a Post call back to Bubble.

Took some effort, but I have that going:

Hey can you choose how many items to bulk upload

ie using dynamic fields can i create new items where the amount of new items might be specified in an input box or as a result of a :count

and how would this look

This looks really cool for direct API use, but are these facilities that enable update via the API calls, also available via the bubble APP connector? i.e. is it possible to use the App connector to write information back to the parent APP without using specific workflows on the parent APP?

If so, how - because I can’t see them listed under any update action on the child app, and they also don’t become available with auto-binding on any field with the parent APP item as GROUP data.