Knowledgebase

Building APIs With FastAPI Print

  • backenddevelopment, backend, errors, guide, howto, solution, zillionkinghost, hosting
  • 0

The modern typed framework.

WHAT IT PROVIDES

Routing Validation and serialisation from type declarations Automatic interactive documentation Asynchronous handling Dependency injection

WHAT THE TYPE DECLARATIONS DO

Define the expected shape of requests and responses.

WHAT THAT PRODUCES AUTOMATICALLY

Validation Clear error messages An API specification Documentation

WHY THAT MATTERS

Documentation and validation stay consistent with the code, because they are derived from it.

WHAT IT SUITS

APIs, particularly Services with many external callers Work benefiting from asynchronous handling

WHAT TO BE CAREFUL WITH

Mixing synchronous blocking calls into asynchronous handlers

WHY

It blocks the event loop, stalling every request.

WHAT TO DO ABOUT BLOCKING LIBRARIES

Use asynchronous equivalents, or run them in a thread pool.

WHAT TO DEFINE

Separate models for input and output.

WHY

So internal fields are not exposed, and inputs cannot set fields they should not.

WHAT TO CONFIGURE

Whether documentation is publicly available.

WHAT TO RUN IN PRODUCTION

An appropriate server, with several workers.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot