Multiple API calls - generated from asset listing?


(Bdebroglio) #1

Matrix Version: fairly new, can’t check right now

Based on a REST resource asset and a linked JSON Data Source, I have 4 items (shadow assets), each containing an ID.

I want to loop over those 4 items, and construct 4 calls to the API, to get specific information based on those IDs.

Is this possible with an asset listing? I couldn’t comprehend how that might work.

Or is there another way?

Thanks!


(David Schoen) #2

Are you constructing calls to an external API? - if so you’ll want to be using a REST Resource and reference it in the listing - this could slow down extremely quickly as all the requests would happen in serial though.

If by “the API” you meant the Matrix JS API or something else to get data out of Matrix it might be better to let us know what data you’re trying to pull out as you may find most of it is available with keywords.

P.s the Matrix version is in the title of the admin interface and is displayed down the bottom left of both admin and Edit+.


(Bdebroglio) #3

Sorry David, was mobile when I accessed the forum.
Squiz Matrix v5.4.7.0

I am making a call to an external API using a REST Resource asset. Then, I’m linking a JSON Data Source asset to the REST Resource asset. This generates 4 Data Source Record Set assets (shadow assets) which is great.

This is a set-up I’ve used many times with success. But in this case, I need to make further calls to the external API based on an ID in each individual Data Source Record Set asset.

The external API doesn’t allow me to get all the information I need in one request.


(Bart Banda) #4

The “easiest” way I can think of doing this is to create Standard Page where you nest (or use %globals_asset_contents_raw:1234% keyword) 4 times in the content that all point to your REST asset to get the data printed in the right format and structure on that Standard Page. Then on another page, nest another REST asset in in which you use %globals_asset_contents_raw:2345% of the first standard Page as the data you want to send to the second REST asset. :sweat_smile: