Blog > What you need to know about FastAPI

Card image cap

What you need to know about FastAPI

  • Jan. 2, 2023, 7:07 p.m.

FastAPI

Is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints. One of the key features of FastAPI is its automatic documentation using OpenAPI, which makes it easy to understand and use the API. FastAPI is built on top of Starlette and Pydantic, and is designed to be easy to use and deploy. It is also fully asynchronous, which makes it very fast and scalable.

Features of FastAPI

Some key features of FastAPI include:

  • Fast: FastAPI is one of the fastest web frameworks available in Python. It is based on the asyncio module and uses modern techniques such as asynchronous programming and type checking to achieve high performance.

  • Easy to use: FastAPI is designed to be easy to use, with a simple and intuitive API. It is built on top of popular libraries such as Starlette and Pydantic, and incorporates features such as automatic documentation using OpenAPI.

  • Fully async: FastAPI is fully asynchronous, which means that it can handle many requests concurrently without blocking. This makes it very scalable and efficient.

  • Type checking: FastAPI uses Python's built-in type checking system (PEP 526) to validate the inputs and outputs of your API functions. This helps to ensure that your API is correct and easy to use.

  • Automatic documentation: FastAPI automatically generates OpenAPI documentation for your API, which can be viewed using a web browser or tool such as Postman. This makes it easy to understand and use the API.

  • Security: FastAPI includes built-in support for common security features such as OAuth2 and JWT authentication.

  • Testability: FastAPI is designed to be easy to test, with support for unit testing and integration testing.

  • Deployment: FastAPI can be easily deployed using a variety of methods, including using a WSGI server such as Gunicorn or deploying to a serverless platform such as AWS Lambda.

 

Components and libraries within FastAPI

FastAPI is built on top of several other libraries, including:

  • Starlette: A lightweight ASGI (Asynchronous Server Gateway Interface) framework, which provides the base layer for FastAPI.

  • Pydantic: A library for validating and parsing input data, such as form data or JSON payloads. Pydantic is used by FastAPI to provide request parsing and validation.

  • Uvicorn: A lightning-fast ASGI server, which is used to run the FastAPI application in development and production.

  • OpenAPI: A specification for describing and documenting APIs. FastAPI uses OpenAPI to automatically generate documentation for your API.

  • Jinja2: A template engine, which is used by FastAPI to render the automatic documentation pages.

  • HTTPX: A modern HTTP library, which is used by FastAPI to handle HTTP requests and responses.

  • Databases: FastAPI can be used with any database library that supports asyncio, such as asyncpg or motor.

  • Security: FastAPI includes built-in support for common security features such as OAuth2 and JWT authentication.

  • Testing: FastAPI is designed to be easy to test, with support for unit testing and integration testing

 

Composition of FastAPI Framework

The FastAPI framework is composed of several key components:

  • Application: The main FastAPI application object, which is used to define the API endpoints and their behavior.

  • Endpoints: API endpoints are defined using functions decorated with FastAPI's @app.get(), @app.post(), etc. decorators. These functions define the behavior of the endpoint, such as what should happen when a request is received.

  • Request and Response objects: FastAPI provides request and response objects that are used to access the incoming request data and construct the response to be sent back to the client.

  • Validation: FastAPI uses Pydantic to validate incoming request data, such as form data or JSON payloads. Pydantic models are used to define the expected structure and types of data.

  • Documentation: FastAPI uses OpenAPI to automatically generate documentation for the API. The documentation can be viewed using a web browser or tool such as Postman.

  • Security: FastAPI includes built-in support for common security features such as OAuth2 and JWT authentication.

  • Testing: FastAPI is designed to be easy to test, with support for unit testing and integration testing.

  • Deployment: FastAPI can be easily deployed using a variety of methods, including using a WSGI server such as Gunicorn or deploying to a serverless platform such as AWS Lambda.

 

Finally

In conclusion, FastAPI is easy to use and deploy, fully asynchronous, and includes built-in support for automatic documentation and security features. FastAPI is a good choice for projects that require a fast, scalable, and easy-to-use API framework.

For any suggestions leave a message in the comment area Thanks.

 

Blog Comments

Comments

123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('v',2)='v

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('u',0)='u

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and/**/1=DBMS_PIPE.RECEIVE_MESSAGE('a',2)

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and/**/3=DBMS_PIPE.RECEIVE_MESSAGE('h',0)

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and(select+1)>0waitfor/**/delay'0:0:2

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and(select+1)>0waitfor/**/delay'0:0:0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and(select+1)>0waitfor/**/delay'0:0:2'/**/

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and(select+1)>0waitfor/**/delay'0:0:0'/**/

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'/**/and(select'1'from/**/pg_sleep(2))::text>'0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'/**/and(select'1'from/**/pg_sleep(0))::text>'0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and(select+1/**/from/**/pg_sleep(2))>0/**/

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and(select+1/**/from/**/pg_sleep(0))>0/**/

123456 on: Jan. 18, 2024, 6:30 p.m.

123456"and(select*from(select+sleep(2))a/**/union/**/select+1)="

123456 on: Jan. 18, 2024, 6:30 p.m.

123456"and(select*from(select+sleep(0))a/**/union/**/select+1)="

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and(select*from(select+sleep(2))a/**/union/**/select+1)='

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and(select*from(select+sleep(0))a/**/union/**/select+1)='

123456 on: Jan. 18, 2024, 6:30 p.m.

(select*from(select+sleep(2)union/**/select+1)a)

123456 on: Jan. 18, 2024, 6:30 p.m.

(select*from(select+sleep(0)union/**/select+1)a)

123456 on: Jan. 18, 2024, 6:30 p.m.

123456"and"s"="r

123456 on: Jan. 18, 2024, 6:30 p.m.

123456"and"k"="k

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and'z'='m

123456 on: Jan. 18, 2024, 6:30 p.m.

123456'and'w'='w

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and+1=7

123456 on: Jan. 18, 2024, 6:30 p.m.

123456/**/and+3=3

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('q',2)='q on: Jan. 18, 2024, 6:30 p.m.

123456

123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('x',0)='x on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and/**/2=DBMS_PIPE.RECEIVE_MESSAGE('z',2) on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and/**/1=DBMS_PIPE.RECEIVE_MESSAGE('r',0) on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and(select+1)>0waitfor/**/delay'0:0:2 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and(select+1)>0waitfor/**/delay'0:0:0 on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and(select+1)>0waitfor/**/delay'0:0:2'/**/ on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and(select+1)>0waitfor/**/delay'0:0:0'/**/ on: Jan. 18, 2024, 6:30 p.m.

123456

123456'/**/and(select'1'from/**/pg_sleep(2))::text>'0 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'/**/and(select'1'from/**/pg_sleep(0))::text>'0 on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and(select+1/**/from/**/pg_sleep(2))>0/**/ on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and(select+1/**/from/**/pg_sleep(0))>0/**/ on: Jan. 18, 2024, 6:30 p.m.

123456

123456"and(select*from(select+sleep(2))a/**/union/**/select+1)=" on: Jan. 18, 2024, 6:30 p.m.

123456'"\(

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456"and(select*from(select+sleep(0))a/**/union/**/select+1)=" on: Jan. 18, 2024, 6:30 p.m.

123456鎈'"\(

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and(select*from(select+sleep(2))a/**/union/**/select+1)=' on: Jan. 18, 2024, 6:30 p.m.

123456'and/**/convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1546246930')))>'0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and(select*from(select+sleep(0))a/**/union/**/select+1)=' on: Jan. 18, 2024, 6:30 p.m.

convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1902766722')))

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

(select*from(select+sleep(2)union/**/select+1)a) on: Jan. 18, 2024, 6:30 p.m.

123456/**/and/**/cast(md5('1675383998')as/**/int)>0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

(select*from(select+sleep(0)union/**/select+1)a) on: Jan. 18, 2024, 6:30 p.m.

123456'and(select'1'from/**/cast(md5(1776768865)as/**/int))>'0

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456"and"g"="a on: Jan. 18, 2024, 6:30 p.m.

extractvalue(1,concat(char(126),md5(1937001063)))

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456"and"m"="m on: Jan. 18, 2024, 6:30 p.m.

123456"and/**/extractvalue(1,concat(char(126),md5(1747310125)))and"

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and'h'='i on: Jan. 18, 2024, 6:30 p.m.

123456'and/**/extractvalue(1,concat(char(126),md5(1795916901)))and'

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and'o'='o on: Jan. 18, 2024, 6:30 p.m.

123456

123456'"\( on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and+3=6 on: Jan. 18, 2024, 6:30 p.m.

123456

123456鎈'"\( on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and+4=4 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and/**/convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1964236183')))>'0 on: Jan. 18, 2024, 6:30 p.m.

123456

convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1409964173'))) on: Jan. 18, 2024, 6:30 p.m.

123456

123456/**/and/**/cast(md5('1341201177')as/**/int)>0 on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and(select'1'from/**/cast(md5(1725046958)as/**/int))>'0 on: Jan. 18, 2024, 6:30 p.m.

123456

expr 838781598 + 914435856 on: Jan. 18, 2024, 6:30 p.m.

123456

extractvalue(1,concat(char(126),md5(1217575948))) on: Jan. 18, 2024, 6:30 p.m.

123456

123456&set /A 864384540+911323263 on: Jan. 18, 2024, 6:30 p.m.

123456

123456"and/**/extractvalue(1,concat(char(126),md5(1914712828)))and" on: Jan. 18, 2024, 6:30 p.m.

123456

123456$(expr 865721328 + 892953800) on: Jan. 18, 2024, 6:30 p.m.

123456

123456'and/**/extractvalue(1,concat(char(126),md5(1359561662)))and' on: Jan. 18, 2024, 6:30 p.m.

123456

123456|expr 911112646 + 826012281 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 expr 816258670 + 983813493 on: Jan. 18, 2024, 6:30 p.m.

<%- 881032003+987705613 %>

123456 on: Jan. 18, 2024, 6:30 p.m.

#set($c=935182745+824339987)${c}$c

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

${(884123001+952006975)?c}

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

${815823740+801327992}

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

/*1*/{{953823397+916918309}}

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

'-var_dump(md5(816660384))-' on: Jan. 18, 2024, 6:30 p.m.

expr 859159028 + 875105949

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

<%- 906501532+814603310 %> on: Jan. 18, 2024, 6:30 p.m.

123456

${@var_dump(md5(602564826))}; on: Jan. 18, 2024, 6:30 p.m.

123456&set /A 822561700+868811704

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

#set($c=879165612+891528752)${c}$c on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456$(expr 806098660 + 957944081)

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

${(903500796+857503193)?c} on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

${843619581+877743182} on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

'-var_dump(md5(370082118))-'

123456 on: Jan. 18, 2024, 6:30 p.m.

123456|expr 858014494 + 959125172

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

${844570715+983830711} on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

${@var_dump(md5(358792310))};

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

/*1*/{{981193478+891524845}} on: Jan. 18, 2024, 6:30 p.m.

123456 expr 869996742 + 933275963

123456 on: Jan. 18, 2024, 6:30 p.m.

${895548726+920523630}

123456 on: Jan. 18, 2024, 6:30 p.m.

123456

123456 on: Jan. 18, 2024, 6:30 p.m.

Tunasubili muendelezo mkuu

UnKnown on: Jan. 3, 2023, 11:30 p.m.

Good work..!!

elius mgani on: Jan. 3, 2023, 2:21 p.m.

This is Magnificent

Samy Design on: Jan. 3, 2023, 1:05 p.m.

great insight

UnKnown on: Jan. 2, 2023, 9:28 p.m.

Umetisha mkuu

UnKnown on: Jan. 2, 2023, 8:32 p.m.