Skip to content

FastAPI

FastAPI is a Python framework for receiving requests and returning data. It helps you define a booking API that a separate website, app or other program can call.

Visit FastAPI

Can you try a FastAPI booking before building the screen?

Yes. Start a local FastAPI project with a request for reserving one of two made-up repair times. Open its interactive API documentation, usually at /docs, to send sample input and see the reply.

A request describes what the caller wants. In this case the caller sends the chosen slot and waits to learn whether the service saved it. The interactive documentation is for inspecting those requests. A customer-facing time picker can be a separate part of your app.

Keep the local example connected to disposable data. Check the connection before sending a test request that writes. If you cannot check it, trace the sample request on paper first.

Which booking checks does FastAPI help you make?

FastAPI can validate that incoming data fits the shape you defined in Python. It can catch a missing required slot. Your booking rules decide whether the requested time exists, is available and can be booked by this caller.

Three cases for the booking endpoint
Sample requestWhat the service should do
Missing slotReturn a validation error if the request model requires a slot. Write no record.
Known, available slotCheck that the caller can book it, save through the database and return the confirmed booking.
Slot taken or access deniedReturn the result appropriate to the rule that failed. Leave the other person’s booking unchanged.

What keeps the records when the API restarts?

Connect a database through a library you choose. FastAPI’s database tutorial uses a local SQLite example. Choose storage that persists for the deployed app and protect the booking rule where the records are written.

Test a missing slot and a repeated booking against disposable data. FastAPI’s TestClient can exercise the request handler from a test without putting a server on the public internet. Verify the stored rows as well as the reply.

If the page and API use different origins, add the page’s origin to the API’s browser-sharing settings. An origin combines the address’s scheme, host and port. Keep the API’s own access checks in place when you allow the browser page to call it.

What runs on the host, and what can you move?

Run FastAPI with an ASGI server such as Uvicorn on a host that supports your Python environment. ASGI is the connection between the Python app and the server. The framework code has an MIT license. Serving requests, storing records and running the website can have separate costs.

Keep the Python code, dependency versions, request definitions and database migration or setup files. Move a private copy first. Have the browser or a test client send the same sample request and check it sees the expected reply and the same saved record.