How to: Display API data in a Card if it comes in an array

If you're using an external API you may not be in control over the format in which the data arrives. However, to ease the development of Cards the data is expected to come in a JSON object format containing key-value pairs. This allows the object values to be referenced in the Card's template.

If your API response comes in an array you'd need to wrap the API result in an object. Depending on how you're accessing the API this can be done in a two ways.

Through Card with API proxy

If you're accessing the API through a Card with an API proxy then you could wrap the API result in an object before passing it to the Card as demonstrated here.

Through a Connector

Generally APIs should be accesses through a Connector. We have demonstrated how you can wrap your API data when using a Connector in the article on creating a Connector with OAuth.