What are Endpoints?

Endpoints are URLs exposed by your backend server that clients can call to perform actions or get data.

Each endpoint is associated with an HTTP method (GET, POST, PUT, DELETE, etc.) and a function in your code.

When your frontend calls an endpoint, FastAPI runs the associated Python function and returns a response.

How Endpoints Work (Example)

Suppose your app wants to show all services:

  1. It sends a GET request to /services/.
  2. FastAPI runs the read_services function.
  3. The function fetches data from the database and returns it as JSON.
  4. The Fapp receives the data and displays it.

If you want to create a booking:

  1. The app sends a POST request to /bookings/ with booking details in the request body.
  2. FastAPI runs the create_booking function, which saves the booking and returns the result.