Correct pattern for retrieving asset URL?

When retrieving multiple entries, the asset URL is in the ‘includes’ array of the response object. In this case, is the recommendation to search each object, find a matching ID, and pull its URL from there? Or to hit the API again to directly pull the asset for a given ID?

When retrieving a single entry, there is no includes array, and therefore no attached assets. I’m assuming the only option here would be to query the API for the asset directly using ID.

Ideally, I would be able to retrieve the URL inline within the ‘items’ array, to avoid additional round-trips to the API and manual searching of the object. Is this currently possible?

Hi @nseth, it is the expected behavior if you are using CURL API, in this case, all the linked entries/assets will be in the ‘includes’ array. Furthermore, when you call /spaces/{space_id}/environments/{environment_id}/entries endpoint, you can specify the level to resolve using include parameter. For retrieving single entries, you can use /spaces/{space_id}/environments/{environment_id}/entries?{entry_id}&include=5 as a strucutre to call the same endpoint.

If you use our official SDKs, you could set the configuration to resolve the links, so the linked entries/assets will be inline within the ‘items’ array. For example, in JS SDK, the configuration is resolveLinks:true.