How to pull API data into a state

Alright, I’ve seen this problem in these forums, but i have not seen a solution that explains what i need.

I’m trying to pull available Twilio phone numbers, from their API and display them to the user to select their number, and purchase.

To do this, I have the API call all worked out. And I was using the bubble API connector to call it. That part works fine, i get the phone number list and ready for the next step.

But this is where I fall apart. I can’t figure out how to call the API and store the data within a workflow. I don’t really want to store this in a database, I’d rather have it ‘realtime’ so that it’s only requested when needed as the list of numbers changes often.

Any thoughts on the right approach to this?
From what I know, I would want to ‘create a list’ based on ‘api data’ but that doesn’t seem to be an option.

Sounds like you just need your Repeating Group to have the same datatype as your API phone number datatype

Then once they run the API call do “Display list in repeating group” and display the “Result of step 1” (or whatever step # the api call is)

1 Like

You are on to something, as i can now see how I can pull data from external source into a repeating group. But what it seems like, is that the API call created a new datatype, and I need to turn that datatype into a specific phone-number datatype that works within my platform.

Mainly, what should i be doing before the “Display list in repeating group” step? That might be where I’m struggling

When you set up your call via the API Connector and initialize it successfully, it exposes a new “Plugin datatype” to use like you see. It’s not really a real datatype like the ones you create cause there isn’t a database or anything for those.

Wouldn’t you want like a button inside the repeating group, that claims that phone number? Then at that point you would do some API call to tell your external API it’s claimed, then do “Create a thing” create the real datatype you use in your database for phone numbers, set all the fields, etc?

Or at the very least in your repeating group, filter out results where the phone # is in your real database already.

I get you now, thank you for that explanation. Exactly, i would only want to have the internal datatype after it’s claimed. So this Repeating group can be considered a temporary list of API data? Just curious, but why would it not go into a ‘state’ ? I feel like a list within a state would be an easier place to put this data. I’m not complaining though, i get it now, thank you!

You could make a custom state, make it a list, and make it the same datatype as your API phone number. Then after your API call do “Set state of an element” and set that list. But then you would just point your repeating group data source to that custom state anyways so probably isn’t much different

Yeah this is a perfect answer, thank you! I got it working, and now off to my next challenge! Much appreciated @tylerboodman

1 Like

regarding pulling lists into a state, is there a record limit? Can I pull 50k, 100k records into a state? Right now, I’m displaying them as a “search” in a repeating group.

I don’t think there’s a limit other than searches being capped at 50K sorted, and 100K unsorted I think? But I would imagine doing anything close to those numbers would crash the user’s browser bringing in that much data

would pulling in 100k records into a state be functionally different than displaying 100k records in a RG via “do a search for” as the data source in that RG element?

I think it would behave pretty much the same. Only thing I can think of is a RG loads in chunks (if the “Show all items immediately box isn’t checked”) so that would save on large searches maybe? Vs custom state might force all 100K unique IDs to get stored on the page. Would need to test and view the network tab in your browser dev tools. Either way I think retrieving 100K things would be a bad idea :joy: