Building APIs With Python

Abhi Agarwal
1 min readApr 23, 2021
Photo by Meruyert Gonullu from Pexels

In this article, we are going to create a “movies” api in python which will have below three endpoints:

  1. /healthcheck: A health check endpoint.
  2. /movies : A GET endpoint which will return a list of movies in JSON format.

3. /movies/<title> : A GET endpoint which will return a movie whose title matches with the given title.

Create a empty project folder called “movies”.

Create a file named movies/MoviesData.json and add the below content.

This data is a subset of data hosted here.

Create a file named movies/MoviesController and add the below content.

We have used Flask here which is a lightweight WSGI web application framework.

To run this python file you need to first install Flask.

pip install Flask

Now go to the “movies” folder in your command prompt and run

python MoviesController.py

Your python web API is now hosted on your machine on port 8080.

Happy Coding!!

--

--