HTTP Methods

Learn to build GET and POST APIs using the FastAPI framework.

HTTP GET is a request method to retrieve data from the server. An HTTP GET method should have the following characteristics:

  • Safe: It doesn’t change or modify the state of the server.
  • Idempotent: It doesn’t result in any side effects for the server.
  • Cacheable: It allows caching of the HTTP response.

Note: All safe methods are also idempotent.

We can easily build a simple HTTP GET API with the FastAPI framework.

Import

Start by adding the following import statements:

Get hands-on with 1200+ tech skills courses.