How to Display a List of Objects from a REST db that returns only Lists of ID's and Single Records

I’m using the Metropolitan Museum of Arts REST API. I can set this up quite easily in the Data Confirguator and create variables to hold the data. The problem comes when trying to create a list/gallery/etc using that data. The MET API (ASFAIK) can only generate a list of of id’s that match a search criteria, or a length record of one id. It cannot return anything that is a list of multiple parameters of multiple object id’s.

For example: The collection request returns just a list of id’s:

[
1,
2,
3,
4,
etc
]

Each of those has to be queried individually to get the full list of parameters I’m interested in:

{
    "objectID": 12345,
    "isHighlight": false,
    "accessionNumber": "50.130.46",
    "accessionYear": "1950",
    "isPublicDomain": false,
    "primaryImage": "",
    "primaryImageSmall": "",
    "additionalImages": [],
etc....

So I can create a list item or card with parameters from one id, but I am stumped at how to iterate though the list of id’s to show them all in a gallery or list.

Any ideas?

Hi, you can do this by looping flow functions on the Logic Canvas. :slight_smile:

I made this pseudo flow where there are 2 page variables idList and itemList. In the beginning you would populate idList with all the id’s you want to retrieve information for, and itemList is an empty list with a schema that matches the objects you want to retrieve.

The flow starts by checking if there are any id’s left to retrieve. If yes, get a record with the first id in the list. Then save that output to itemList. Then remove the used id from idList and check again.

Once all id’s have been used and removed, itemList should have all the desired items and execution of the loop stops when the IF condition node returns “true” because idList is empty.

Thanks Mari, that worked great it took me a while. When I went looking for the APPEND and REMOVE functions I couldn’t find them. What I ended up with is

. It took some trial and error. Why couldn’t I find the same functions as you suggested. Is your composer a different version?

Also it seems like the options for the first element in a repeating component only shows suitable options when the “Repeat With” option is set. Since that is underneath the first element options it’s not at all obvious that that has to be set first. Maybe the “Repeat With” option should be moved to the top and then what follows will be in context.

Hi Jon! APPEND and REMOVE are just aliases for WITH_ITEM and WITHOUT_ITEM, sorry for forgetting to mention that.

image

Thanks for the feedback on the ordering of properties. I think the “Repeat With” option is placed at the bottom since every component can be used either by itself or as a repeated component, so the line between what is a “repeated component” and what is not is a little blurry. It could be a good feature if components that will likely be repeated, such as list items, would have the “Repeat With” option at the top. :slight_smile:

1 Like

Maybe instead of moving the “Repeat With” option to the top, put a checkbox of switch at the top that says something like “Use a Repeated Component”? That then sets the context for the all the rest of the options.

1 Like