Testing your API
Run & Debug
Last updated
Run & Debug
Last updated
You can test your API using Run & Debug. It's a powerful tool that can be used on your Function Stacks to verify whether or not they are working properly. It can be found on the top right-hand corner of any API, Function, Addon or Task.
Example Request
In this example API, we are using an input to ingest a number, and then in our function stack, we first set a new variable called x1 to the same value of the input. Then, in the next two steps, we are adding 1 to the previous contents of the x1 variable. So, if our input is 5, our result is 7.
If you are running requests that produce large amounts of data, it can cause delays during Run & Debug. It can even cause the API Test to completely stall out if the payload is very big.
When you click Run & Debug, you are presented with a panel to fill in any inputs you have established, and an option to either Run or Debug.
Authentication - Select a user to authenticate with, if your endpoint requires authentication
Authentication Extras - Add additional data to the generated authentication token
Inputs - Populate any inputs needed to test your endpoint
Reset - Resets your inputs and input schema to the default values
Format - Formats the JSON added to the input panel. Good if you are pasting a payload from an external source into Xano when testing your function stack.
Debug - Launch the Debugger
Run - Run your function stack
Clicking RUN will run our function stack as is, which returns our expected result of 7.
Input / Result - View the provided inputs and the result of your function stack execution.
Result - The response of your test run and the total execution time
cURL - Copy a cURL command to your clipboard for easy testing of your API outside of Xano
Auth - Copy the Authentication Token used to test your API
Once your function stack finishes executing, you can reset your inputs and run it again, view the result below the input panel, or quickly generate a cURL command and copy it to your clipboard to test your API externally.
Your inputs will be saved in session storage, so you can come back to the same test data later. If you close your browser or log out, the values will be lost.
Click DEBUG from the bottom of the Run & Debug panel to open the debugger.
This will run your function stack as normal and provide a dedicated set of tools to help you understand exactly what's happening during execution.
Step Over - When working with nested function stacks (custom functions or middleware), if you don't need to debug those, just step right over them and continue with the next function in your function stack Keyboard Shortcut - Arrow Up or Arrow Down
Step Into / Step Out - Step into or out of a nested function (custom function or middleware) and continue the debugging experience seamlessly Keyboard Shortcut - Alt + Arrow Up or Alt + Arrow Down
Continue - Continue with execution of your function stack Keyboard Shortcut - Arrow Right or Arrow Left
Enable Breakpoints - Enable or disable breakpoints as a whole
Step Forwards / Step Backwards - Toggle forward or reverse execution of your function stack
Result - View the result of your completed execution
Watches - Use custom Javscript expressions for more complex data monitoring or calculation as your function stack executes
Variables - View the current contents of your variables as the function stack executes
Copy 📄 / Add Watch 👁️ - Copies the variable's current contents, or adds a variable to your Watches list
Breakpoints - View the currently established breakpoints in your function stack
Breakpoints enable you to determine when execution of your function stack pauses while using the debugger. While the debugger is open, you can move your mouse over any of the functions in your function stack to add a breakpoint by clicking the lighter red circle that appears. When you click on this icon, it turns fully red 🔴 to indicate a breakpoint has been added.
You can also see all of your active breakpoints listed inside of the debugger, which updates automatically as you change breakpoints in your function stack.
You can quickly enable and disable breakpoints as a whole by using the ENABLE BREAKPOINTS toggle at the top of the debugger.
Watches are Javascript-based statements that enable custom retention or manipulation of data generated as your function stack executes.
In this example, we are running a For Each loop on some database records. For each iteration of the loop, it performs some calculation on a timestamp field, but during debugging, not having this value human readable can make understanding if everything is working as expected more difficult.
By adding the JS code below as a watcher, we can get a human readable version of the manipulated timestamps as we step through our execution.
In this example, we're calling an external API and looping through some products. As we step through execution, we want to see an updated list of each product that's being added to our database without having to go through whole JSON objects.
We can definitely just add a breakpoint to our conditional statement and check the value from the Variables section of the debugger, but adding some watches can make this data more easily visible.
By adding the two watchers listed above, we get real time monitoring of the conditional statement's expression and the product title itself, and can quickly step through each iteration of the loop to understand exactly why an item may or may not qualify.
Timing Details - View a detailed breakdown of how long each statement took to execute.