Xano's add-on feature is a game-changer for developers and no-code enthusiasts alike, allowing you to extend the data of a single API request from different data sources or database tables, much like GraphQL. However, what truly sets Xano apart is the ability to customize the response of these add-ons, enabling you to get rid of any unnecessary or unwanted data in your response. In this guide, we'll explore the different ways you can tailor your add-on responses to suit your specific needs.
There are two primary ways to customize the response of an add-on in Xano:
Within the API Endpoint: When you're working on an API endpoint, you can access the add-on settings by clicking on the orange "Add-on" button next to the add-on you want to customize. This will open up the add-on settings, where you can click on "Customize the Response" to select or deselect the fields you want to include or exclude from the response.
Within the Add-ons Library: Xano provides an "Add-ons" library on the left-hand side of the interface. By clicking on an individual add-on in this library, you can access its settings and customize the default response for that add-on across all instances where it's used.
Let's say you have an API endpoint that fetches all your merchant records and includes an add-on to retrieve the associated deals for each merchant. Here's how you can customize the response for that add-on:
Now, when you run the API endpoint, the response for that specific add-on will only include the fields you selected.
If you want to set a default response for an add-on across all instances where it's used, you can do so in the Add-ons Library:
Now, whenever you use this add-on in any API endpoint, the default response will be the one you customized in the Add-ons Library, unless you override it by customizing the response within the API endpoint itself.
If you've customized the default response for an add-on in the Add-ons Library, but you want to override it for a specific API endpoint, simply follow these steps:
The customized response you've set within the API endpoint will now take priority over the default response set in the Add-ons Library for that specific add-on instance.
It's important to note that when you add a new field to a database table, Xano's behavior will depend on whether you've customized the response for the associated add-on or not:
To illustrate this, let's say you add a new text field called "new" to your deal table. If you've customized the response for the "Deal of Merchant" add-on, the "new" field won't be included in the response. However, if you haven't customized the response, the "new" field will be automatically added to the response.
By understanding the hierarchy of how these customizations work, you can ensure that your API responses only include the data you need, leading to optimal performance and a better overall user experience.
Remember, Xano's documentation provides detailed information on this topic, so be sure to consult it for further guidance and examples.
Join 100,000+ people already building with Xano.
Start today and scale to millions.
Start building for free