How to make APIs with Flask and use it with Streamlit Python

Aditya Mangal
2 min readMar 3, 2023

It is very amazing to make APIs and use them anywhere in development but how to make them ?? 🤔🤔

What is API?

APIs, or Application Programming Interfaces, have revolutionized the way software applications communicate with each other. APIs enable different applications and systems to share data and services seamlessly, making it possible for businesses and individuals to create new and innovative products and services.

The beauty of APIs lies in their ability to unlock the power of data and services that were previously inaccessible or difficult to use. With APIs, developers can access and use data from a wide range of sources, including social media platforms, government databases, financial institutions, and more. They can also use APIs to build new applications that leverage the services and capabilities of existing systems, such as payment processing, messaging, and location services.

I think I should start coding as the theory part always torture me 😅😅. I am going to use Flask and Streamlit libraries. You can go through the documents to get an insight into functionalities.

Install Flask and Streamlit Dependencies

pip install Flask
pip install streamlit

Let's divide the code into two files. The first file is to run the server so that it can expose through API. And second file is to show output on the web page through Streamlit.

In the file, the data function is used to execute queries and return the responses. It can be modified with the use of services that can provide responses of Deep Learning models or Artificial Intelligence models.

To host API, run in the terminal and keep it running so we can check the API on the web page.


It will create the API at http://localhost:1111/check_api

Now, come to the file which is going to use to run streamlit library. As we want to render the response on the web page.

To run, run the below code in terminal

streamlit run

Hurray, we have created an API. Now, it is your turn to make APIs for Deep Learning models or for other queries. You can check out my GitHub repo here.



Aditya Mangal

My Personal Quote to overcome problems and remove dependencies - "It's not the car, it's the driver who win the race".