Xano Documentation

List of Items

Use Addons to return a list of items that belong to something.
The below example details how to create an Addon from the Query all Records function. Additionally, it shows how to use an Addon to return a list of items.
The example is for a GET API endpoint that is returning all the records from the merchant table. The Addon will extend the response with the deal table, showing a list of all deals associated with the merchant record.
Creating an Addon and returning a list of items:
  1. 1.
    Within, the Function Stack, you can open a Query all Records function. Next, go to the Output tab and select the "+ Addon" button underneath the response body.
In this example, we are creating an Addon directly from the Function Stack. Within the Query all Records function, in the Output tab, we are able to create an Addon.
2. Next, we will be given a choice to create a new Addon or choose to connect an existing one (if we previously created one).
In this example, we will choose create a new Addon.
3. Then, choose which database table to want to add to the response. This allows us to determine which data we want to add in our API request.
In this example, we will add the "deal" table to our response.
4. Choose how you'd like the data returned. There are several options that will be covered in the subsequent pages:
In this example, we will choose a "List of items" for how we want the data returned.
5. Now, select how to connect the database tables together. Here, we must determine how the tables are mapped together. This is usually done by a table reference to make a relationship between tables in our database. We can also add settings for sorting, paging, and distinct records during this step.
In this example, we connect the "merchant" table to the "deal" table with deal.merchant_id. Which is the table reference to the merchant id in the deal table.
6. We can name the Addon or Xano will provide a default name.
In this example, the Addon is named deal_of_merchant.
7. Lastly, we can confirm how the Addon is mapped and optionally customize the values returned in the response.
In this example, the merchant_id of the Addon (which is from the deal table) maps to the id of the merchant table.
Now we can see that the response will be extended with the Addon we created.
In this example, we see the Addon will extend the response of the merchant records with a list of the deal_of_merchant.
Finally, when we run the API endpoint. The response is extended with the data from another table thanks to the Addon!
In this example, the Addon extends our API endpoint response. We have a list of 3 deals that are associated with the merchant Zuni Cafe.