Api And Debugging

Xano - Getting Started Step 2: the API

Summary

In the previous guide, we covered how to set up your database tables and add data to them. This time, we'll dive into understanding how your API interacts with your database.

What is an API?

Think of your database as a filing cabinet that holds all the data and information for your application. The API acts as an office clerk, processing requests and managing the flow of data between your database and the outside world.

Whenever you need to retrieve data from the database, you have to go through the API. It will handle your request, search the "filing cabinet" for the required data, process it, and relay it back to you in an understandable format.

Accessing the API Page

To access the API page in Xano, you can either click the "API" link in the top navigation bar or use the left sidebar menu. Once there, you'll see an "API group" called "public." Click "Explore" to find all the CRUD (Create, Read, Update, Delete) API endpoints generated for each of your database tables during the Jumpstart process.

Xano also provides a handy link to the auto-generated documentation in Swagger, making it easy to understand and work with your API endpoints.

Anatomy of an API Endpoint

Let's explore the anatomy of an API endpoint by looking at the "POST" endpoint, which is used to create a new record in the "merchant" database table.

  1. Inputs: These are the pieces of information the API needs to understand and process your request. In this case, the inputs are the "name" and "description" of the merchant.
  2. Function Stack: This is the core logic that defines what your API endpoint does. For the "POST" endpoint, it adds a new record to the "merchant" table.
  3. Response: This is the data you'll receive back from the API after it has processed your request. In our example, the response will be the newly created merchant record.

Testing API Endpoints

One of the great features of Xano is the ability to run and test your API endpoints directly within the tool. Click the "Run in Debug" button in the top-right corner to open a new window. Inside the green parentheses, you can provide the required inputs for the API endpoint.

For example, let's test the "POST" endpoint by adding a new merchant:

("High Street Deli", "Deli Sandwiches")

Hit "Run," and you'll see a success message along with the response containing the new merchant record.

Next, let's look at the "GET" endpoint, which queries all the merchant records. Since there are no inputs required, you can simply click "Run" to retrieve all the records from the "merchant" table.

Next Steps

This guide covered the basics of understanding how your API interacts with your database. Be sure to check out the other guides on using the "UPDATE" and "DELETE" endpoints to round out your knowledge of CRUD operations.

In the next guide, we'll explore how to connect Xano to a front-end application, bringing your backend to life!

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