Retrieving nested, or multidimensional data, can easily be achieved with the Pro Plugin.
The Pro Plugin allows you to step down through multidimensional array data using array keys and indexes to get your data. This works in both the template function and also the shortcode.
For an example of the array data, pretend that your API returned the data below but you only needed to simply return the ‘id’ of ‘Horse’, which would give you the expected value of ‘14377’:
Array(
[name] => Array(
[0] => Array(
[nickname] => Cowboy,
[id] => 24538
),
[1] => Array(
[nickname] => Yeehaa,
[id] => 49890
),
[2] => Array(
[nickname] => Horse,
[id] => 14377
)
)
)
The shortcode and template function to retrieve the data would look something like this:
[wpgetapi_endpoint api_id="my_api" endpoint_id="my_endpoint" debug="false" keys="name,2,id"]
wpgetapi_endpoint( "my_api", "my_endpoint", array( "debug" => false ), array( "name", 2, "id" ) );
This is just a made up example, but in both cases it would retrieve the data for “my_api”, “my_endpoint” and would get the data associated with the “name” key first, then get the data associated with the index of “2” and finally then get the data with the “id”.