How can I access Option sets through the API?

Hello!

I’m trying to access the Option set through the API to map incoming values to my option set. Is there a way to access those option sets through the APIs?

Regards,

2 Likes

I’m breaking my head trying to figure it out, too. I don’t think it’s possible yet (link a comment on a thread).

Let me know if you figure it out.

1 Like

@rico.trevisan @joran1 Did you guys have any luck on this one? (or any workarounds?)

I know to get the database in a json format, we can enable the data api and the GET the meta endpoint.

https://app-name.bubbleapps.io/version-test/api/1.1/meta

Is there an endpoint to get all the option sets?
Perhaps @Bubble know or maybe @ZeroqodeSupport ?

Thanks
ZubairLK

1 Like

Any update on this one? If options sets are not accessible via API, I think using this feature is a serious risk for any app. .

2 Likes

Hi it’s interesting

1 Like

new finds about this?

1 Like
                "Fake": {
                    "type": "option set",
                    "description": "'Fake' field of the current Client"
                },

This popped in my Swagger schema.

I guess it’s time for a celebration :tada:

1 Like

Can you explain further?

@eve should we open issue this in a feature request forum? is there a work around of some sort?

This popped in my Swagger schema.

@pierre7 did you manage to get a full list of all the options in this set through swagger specification?

:sweat_smile: I don’t think I can. I’ve been reading and re-reading the threads and I can’t remember what the hell I meant. Sorry.

Here’s what I found out so far:

  • You cannot access options sets directly via API.
  • Thus you cannot update them.

Workaround idea :bulb:

I have not tried this yet, but given you can access the swagger data and that data shows if a field is an option set or not, I’m guessing you could do this

  1. Create a data type.
  2. In that data type, create fields for each option set as lists.
  3. In that data type, add all your option sets. Add each as lists.
  4. Create an item in the database and add all the possible options.
  5. Make that Data Type accessible via the data API.

Looking at the swagger file https://[your app]/version-test/api/1.1/meta will give you the field names. Example:

Pulling up the items of that data type will give you the possible combinations. GET https://[your app]/version-test/api/1.1/obj/[your data type]
image

In my example it only shows one item in the option field, but if you put a list of options it should work.

3 Likes

Simply create an backend API workflow that returns a list of options.
You can then call it either internally in Bubble or externally to get the options.

5 Likes

Works perfectly!



image

1 Like

how to get all option sets with attributes

1 Like

I think it’s possible. @lindsay_knowcode’s tool, PlanBBackup, was extracting option sets and even disabled tables from the Data API (if I remember correctly from when I last used the tool, I’m not sure if that still doing the same).

i looked into swagger and meta but couldn’t see anything :confused:

1 Like

You can get to the option set content with JavaScript in the browser or extract from the app download. It’s a bit fiddly as option sets can take custom types as attributes (and option set types ) so resolving them to a sane structure is fiddly. But it is possible. Planb does it to some degree, for exporting to an another database or backup. If you are looking to convert to another database I’d suggest you refactor out the any option sets that aren’t just two dimensional - so as to make them easily convertible to “Enums” in Postgres terms.

1 Like