Building Restful API with Flask, Postman & PyTest - Part 1(Read Time: 6 Mins)
Tags: webdev, beginners, python
Published: 2019-01-06 11:01:05

---
title: Building Restful API with Flask, Postman & PyTest - Part 1(Read Time: 6 Mins)
published: true
description: How to start building APIs with Flask, Postman & PyTest
tags: webdev, beginner, python
---
![Photo by Christopher Burns on Unsplash](https://thepracticaldev.s3.amazonaws.com/i/ox6hxide0m857l3crfdo.jpg)

## Introduction
For the first part of the 3 part series of the building Restful API with Flask, Postman and PyTest.

I will be covering the explanation of the libraries and tools used to create a **expenses manager** project based upon [Testing Python Applications with Pytest](https://semaphoreci.com/community/tutorials/testing-python-applications-with-pytest) so that you will understand why you might use these tools or libraries as part of your development process to develop APIs in Flask. 

Whereas in part 2 of the series, I will cover the **API design** of the expenses manager and **mocking** API endpoints in **Postman**. 

Finally, for part 3 we will be implementing the API in **flask** with **test cases** built using **PyTest**. 

## Journey from a Django Developer to an API Developer
When I first started to become a **Django** developer, I learnt the basics on how to build a basic website with **Django**, **SQL** Database and **JQuery**. 

As I grow in experience, I realised the importance of building single page web apps by using front-end frameworks with Django as backend. 

I learnt to combine my understanding of front-end framework from Udacity with **Django Rest framework** to develop APIs for the front-end to consume for my backend during my work. 

## Building APIs using Flask
Flask is another python based web framework that is considered the **go to**  framework for developing Restful APIs. 

I had come across multiple articles or sources in **freeCodeCamp** due to its flexibility & simplicity to create APIs without much effort. 

Coming from experience using **Django Rest Framework**, I was quite sceptical of it when I first started to use it.

With time **flask** wins me over but due to flask's flexibility, it can be painful in learning. 

Due to the reason that there is no **one specific way** in building an API compared to **Django Rest Framework**.

## Mocking & Testing Using Postman
While building APIs, I started to use tools that allow me to test my API at a much faster pace.

One of these tools is Postman, which I used it as a testing tool and API documentation for my front-end developer initially. 

But I found out later that you can break the **interdependence** problem of front-end and backend through using the Postman's mock server feature. 

## Breaking API Dependence Workflow of Frontend & Backend.
With Postman's mock server, a front-end developer can focus on integrating mock endpoints without relying on the backend.

Whereas for the backend developer, they could focus on providing the front-end with a working endpoint and swap it around when it has completed. Further reducing the time to ship for the development team.

## Creating Test Cases with PyTest
PyTest is my goto testing framework in python as it is easy to learn and has lesser boilerplate code compared to the default installed **unittest** library. 

Which follows the **JUnit** style of implementation which could be intimating when you first started to use.

## Conclusion
I hope the first part of the series explains the rationale on using tools or libraries like Postman and Pytest can help in speeding up the development process.

Please stay tuned for part 2 and part 3 of the series to teach you on how to create mock endpoints and implement it in Flask with test cases in Pytest.

## Links
* [Flask](http://flask.pocoo.org/)
* [Postman](https://www.getpostman.com/)
* [PyTest](https://docs.pytest.org/en/latest/)
* [Python Testing with pytest: Simple, Rapid, Effective, and Scalable](https://www.amazon.com/Python-Testing-pytest-Effective-Scalable/dp/1680502409)
* [Testing Python Application With PyTest](https://semaphoreci.com/community/tutorials/testing-python-applications-with-pytest)
* [The Cleaning Hand of Pytest](https://blog.daftcode.pl/the-cleaning-hand-of-pytest-28f434f4b684)

If you like my article either sign up for [Max's Weekly Newsletter](https://mailchi.mp/a1fd1bd1de4a/devto) or you can **follow** to get the latest update of my article on **Dev** 

This post was originally posted on max's blog at [Building Restful API with Flask, Postman & PyTest - Part 1](https://www.maxongzb.com/building-restful-api-with-flask-postman-and-pytest-part-1-read-time-6-mins/) and picture from [Photo by Christopher Burns on Unsplash](https://unsplash.com/photos/8KfCR12oeUM)