Python Advanced:
APIs
TAKEAWAYS
02
What is API?
1 API stands for Application Programming
Interface.
2 It is a way through which different software
programs talk to each other.
3 requests is a popular Python package used to
call APIs from Python code.
4 FastAPI is a popular web framework in Python
that is used to build APIs.
5 GET, PUT, POST and DELETE are four frequently
used REST API calls
03
Calling APIs With
requests Package
1 The requests library in Python simplifies making
HTTP requests to APIs, supporting methods like
GET, POST, PUT, DELETE, and more.
2 Using [Link]() or [Link](), you can
easily fetch data from or send data to a server,
with parameters or data passed as function
arguments.
3 Handling the response involves checking
response.status_code to ensure the request was
successful and using [Link]() to parse
JSON data returned by the API.
4 Exception handling is crucial when making API
calls.
04
Building APIs With
FastAPI
1 FastAPI is a web framework that lets you build
servers that can serve inference requests.
2 FastAPI is a modern framework that offers
several benefits over other options such as
Flask. The benefits are:
Speed
In-built data validation
In-built documentation
Faster code development