Expanding nested content on delivery API

Hi,
We are currently working on replacing a prior implementation of our content delivery with the Umbraco delivery API. In that context we are experiencing some difficulties with properly expanding the nested blocklistitem objects we select in or backoffice.

Is there a way to recursively (till the lowest depth) expand all properties on an item retrieved using it ID? The approach that we are following for now is the good ol’ properties[$all.. and so on, until we think we’ve hit the lowest level. Is there a parameter that allows us to expand, depth-first so we get all of the relevant content, even in nested content pickers?

Hi @Rosenkilde-dev

Unfortunately there’s no single wildcard parameter that recursively expands all nested content to unlimited depth you’re on the right track with expand=properties[$all], but the Delivery API requires you to be explicit at each level.

For deeply nested Block List items, you need to chain the expand syntax level by level. The structure for block list expansion is:

?expand=properties[blockListProperty[content[properties[$all,nestedPicker[properties[$all]]]]]]

points about block list expansion thouggh:

  1. Block list items are elements, not content , Each block has a content element (and optionally a settings element), so you expand via content[properties[...]] rather than treating them as content items.

  2. The items array is implicit ,When you expand a block list property, all items in the list are expanded using the same pattern. You don’t need to specify items[...] in the expand syntax.

  3. For nested content pickers within blocks — If a block’s content element has a content picker property, you expand it like any other nested property:

    properties[blockListProperty[content[properties[contentPicker[properties[$all]]]]]]
    
    

It’s verbose, but that’s by design ,the API intentionally avoids unbounded recursive expansion to prevent performance issues on deeply nested content trees.

A couple of things that might help:

  1. Know your depth upfront — if your content model has a predictable nesting depth, just write the expand string to match it. Three or four levels is usually the deepest you’d realistically need.

  2. Use fields to trim the response — once you’re expanding deeply, the payload can get large. Combine expand with fields to only return the properties you actually need:

    ?expand=properties[blockListProperty[content[properties[$all]]]]&fields=properties[blockListProperty]
    
    
  3. Consider restructuring the content model — if you’re finding yourself needing very deep recursive expansion, it’s sometimes a sign that the content model could be flattened or that content pickers could be replaced with Block List entries that already include the data inline.

  4. For settings elements — If you need to expand settings properties as well:

    ?expand=properties[blockListProperty[content[properties[$all]],settings[properties[$all]]]]
    
    

good luck

/bishal