Api And Debugging

Addon Response Customization (Similar to Graph QL query)

Summary

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.

Step 1: Accessing the Add-on Response Customization

There are two primary ways to customize the response of an add-on in Xano:

  1. 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.
  2. 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.

Step 2: Customizing the Response Within the API Endpoint

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:

  1. Click on the orange "Add-on" button next to the add-on you want to customize.
  2. In the add-on settings, click on "Customize the Response."
  3. You'll see a list of all the fields included in the response. Deselect the fields you don't want to include in the response.
  4. Click "Save" to apply the changes.

Now, when you run the API endpoint, the response for that specific add-on will only include the fields you selected.

Step 3: Customizing the Default Response in the Add-ons Library

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:

  1. Click on the "Add-ons" library on the left-hand side of the Xano interface.
  2. Select the add-on you want to customize.
  3. In the add-on settings, navigate to the "Output" tab.
  4. Click on "Customize the Response."
  5. Select or deselect the fields you want to include or exclude from the default response.
  6. Click "Save" to apply the changes.

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.

Step 4: Overriding the Default Response

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:

  1. Within the API endpoint, click on the orange "Add-on" button next to the add-on you want to customize.
  2. In the add-on settings, click on "Customize the Response."
  3. You'll see the customized default response from the Add-ons Library.
  4. Select or deselect the fields you want to include or exclude for this specific API endpoint.
  5. Click "Save" to apply the changes.

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.

Step 5: Handling New Fields

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:

  • If you've customized the response: The new field will not be added to the response automatically. You'll need to manually select it if you want to include it.
  • If you haven't customized the response: The new field will be automatically added to the response.

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.

This transcript was AI generated to allow users to quickly answer technical questions about Xano.

Was this helpful?

I found it helpful

I need more support
Sign up for XanoSign up for Xano

Build without limits on a secure, scalable backend.

Unblock your team's progress and create a backend that will scale for free.

Start building for free