FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python-type hints. One of FastAPI's main goals is to be easy to use and learn. It has a number of features that make it very convenient to use and allow developers to build APIs more quickly and with less code.
Let's get to some introduction about REST and RESTful API.
REST (Representational State Transfer) is a software architectural style that defines a set of constraints to be used for creating web services. RESTful APIs are APIs that follow the REST architectural style and guidelines.
Some of the key principles of REST include:
Client-server architecture: The client (e.g., a web browser) sends a request to the server (e.g., a web server), and the server returns a response.
Statelessness: The server does not store any state about the client sessions in between requests. All the information needed to handle a request is included in the request itself.
Cacheability: RESTful APIs should be designed to be cacheable, meaning that clients can cache the responses to improve performance.
Layered system: A RESTful API can be used by multiple clients, such as web browsers, mobile apps, or other servers. The API itself is not aware of the specific client that is using it.
RESTful APIs are often used to build web services that are lightweight, maintainable, and scalable. They are widely used in modern web development and are a key part of the API (Application Programming Interface) ecosystem.
Based on the introduction about REST, RESTful API, and FastAPI above let's go deep into how to create RESTful API using FastAPI. We are going to create an API to add and get users using FastAPI.
To create an API to add and get users using FastAPI, we need to follow these steps:
After Running the application, we need to navigate to http://127.0.0.1:8000/docs to view our APIs, and will be shown as follows:
All of Two APIs:
The POST API to create a User:
The GET API to get a list of added Users:
You can get all of the work above from the GitHub link Sample FastAPI APIs.
For any suggestions leave them in the comment area below, Thanks.
123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('m',2)='m
123456'/**/and/**/DBMS_PIPE.RECEIVE_MESSAGE('o',0)='o
123456/**/and/**/3=DBMS_PIPE.RECEIVE_MESSAGE('a',2)
123456/**/and/**/2=DBMS_PIPE.RECEIVE_MESSAGE('g',0)
123456'and(select+1)>0waitfor/**/delay'0:0:2
123456'and(select+1)>0waitfor/**/delay'0:0:0
123456/**/and(select+1)>0waitfor/**/delay'0:0:2'/**/
123456/**/and(select+1)>0waitfor/**/delay'0:0:0'/**/
123456'/**/and(select'1'from/**/pg_sleep(2))::text>'0
123456'/**/and(select'1'from/**/pg_sleep(0))::text>'0
123456/**/and(select+1/**/from/**/pg_sleep(2))>0/**/
123456/**/and(select+1/**/from/**/pg_sleep(0))>0/**/
123456"and(select*from(select+sleep(2))a/**/union/**/select+1)="
123456"and(select*from(select+sleep(0))a/**/union/**/select+1)="
123456'and(select*from(select+sleep(2))a/**/union/**/select+1)='
123456'and(select*from(select+sleep(0))a/**/union/**/select+1)='
(select*from(select+sleep(2)union/**/select+1)a)
(select*from(select+sleep(0)union/**/select+1)a)
123456"and"b"="l
123456"and"d"="d
123456'and'b'='g
123456'and'k'='k
123456/**/and+3=6
123456/**/and+3=3
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456'"\(
123456
123456ι'"\(
123456
123456'and/**/convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1793883807')))>'0
123456
convert(int,sys.fn_sqlvarbasetostr(HashBytes('MD5','1284042233')))
123456
123456/**/and/**/cast(md5('1088428902')as/**/int)>0
123456
123456'and(select'1'from/**/cast(md5(1179765920)as/**/int))>'0
<%- 984022361+870539030 %>
123456
extractvalue(1,concat(char(126),md5(1292753711)))
123456
#set($c=974801372+946116530)${c}$c
123456"and/**/extractvalue(1,concat(char(126),md5(1440662276)))and"
${(935743866+970968311)?c}
123456
123456'and/**/extractvalue(1,concat(char(126),md5(1583733221)))and'
${932823767+892691203}
123456
expr 967009043 + 905316495
123456
/*1*/{{888178987+860859995}}
123456
123456&set /A 865899647+838971647
123456
123456
123456
123456$(expr 839325197 + 892779207)
123456
123456
123456
123456|expr 938822207 + 971926842
123456
123456
123456
123456 expr 824893637 + 852856608
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
${811743020+841994564}
123456
123456
'-var_dump(md5(321101647))-'
123456
123456
${@var_dump(md5(302072321))};
123456
123456
That is good bro
Hats off π
Bravo ππ
Good Stuff.
keep it up,
This is so nice, the blog post explains it all. Congrats ππΎππΎππΎ
Thanks @Abdul for the Questions, the next article will cover Capability of FastAPI more over I will show an examples of APIs that includes Database connection with ORM (Tortoise ORM), I hope you will learn more on that article
Also would like you to expand on Object Relational Mapping pydantic is using, and the database thats syncing with model defined in the example.
ππ½