Fun Personality check with REST API in 7 minutes.
with Python and Flask
From some time now I have been working in machine learning and I have got to understand, in this incipient era of the distributed system world, there is an immensely colossal need of sharing resources, data etc. across the world but without compromising privacy along with universally understandable and facile use of communication. Having said that, the question now is “Can API be the answer to this”?

Contents :
- Introduction
- API
- Basics of REST API
- Deploying the Flask Application
- Advantages and Disadvantages of Rest API
- Conclusion
- References
I. Introduction
In the role of Machine Learning Engineer or Data Scientist, people often use API to retrieve information like weather forecast, news articles , stock prices updates etc from the model predictions. I had never worked on API before. So I learned a lot in the process of making a simple Flask API and the deployment. However, there is some complexity in the deployment of machine learning models. Hence I wished to share the process as well as pitfalls with you. I have built a Flask API which would make HTTP requests for names and return a JSON formatted response of the person’s personality from the initial letter of their name and a very beautiful quote. The purpose of this blog is to show a simple REST API using Python, Flask and JSON.
II. API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software.(-Wikipedia). Simply, it acts as a bridge between softwares and devices.
It is so simple.
III. Basics of REST API
a. REST API
A representational state transfer (REST) was formally introduced by Roy Fielding in his doctoral dissertation in 2000. It’s a cluster of architectural components, design principles, and interactions used to build distributed systems that includes media like text, video, etc.
It uses HTTP requests to GET, PUT, POST and DELETE data.GET requests are used to retrieve data from a server. POST requests are used to send data to an API to create or update an entry. PUT works similar to POST, however, PUT requests are idempotent, denoting the application of this method multiple times can be done without changing the final result. Finally, DELETE requests are used to delete particular entries within the database.
The main intent behind a REST API is composed of three key items: url, path, request. When a client makes an HTTP request to an API in order to retrieve data, the first item that must be called is the URL. The URL generally encompasses the sites domain, directories, and request which follows the structure shown below in Fig. 3.
When a client application requests an URL to REST API through HTTP protocol,Once a request is received, the API delivers the output in a format that the application can consume, such as a JPEG image, HTML page, or JSON.
b. JASON
JSON, JavaScript object notation, is favored as a message format because it can be read by any programming language, is human and machine-readable, and is lightweight. In this way, RESTful APIs are more flexible and may be easier to set up.
c. Flask
Flask Python is a lightweight WSGI (Web Server Gateway Interface) web application microframework, which is able to have a web application running with only a few steps and nearly no setup. This framework’s simplicity and robust control over what you would like in your application have it one in all the most used web development frameworks. Flask-RESTful is an extension for Flask which is used to add support for quickly building REST APIs.
Looking for a way to support my learning journey? Buy me a book and be a part of my intellectual growth! 📚🌱
IV. Deploying the Flask Application
When the API completes and functions well as predicted, the subsequent logical step is to deploy the application to a server. I deployed an API with Heroku. Heroku is defined as a PAAS, container-based platform which is generally utilized by developers to deploy, manage, and scale the applications. Links are shared to have fun with the personality check and exquisite quote.
V. Advantages and disadvantages of REST API
a. Advantages of REST API
- Simple to understand and easy to explore & discover.
- Organizes complicated applications & makes it accessible to use.
- High load is managed by HTTP proxy server & cache
- Integrate data with a website without any complications.
- Flexible in data formats like XML or JSON.
b. Disadvantages of REST API
- No awareness of state which makes the client application heavy and problematic to maintain.
- Lack of security for confidential data passage between client and server.
VI. Wrapping Up
Woah !! Thank you so much to anyone who has made it this far. I hope you have found this article helpful with a little fun ;) . Now, it’s your turn to build your own APIs from scratch. If you get errors, trapped in middle of nowhere or just want to say hi, please leave a comment.
You can find the code in python on Github.
You can visit the ML Deployed app here.
You can reach me on LinkedIn.
Good Luck! ☘️
VII. Refrences
1] https://www.buzzfeed.com/farrahpenn/what-does-your-first-name-say-about-your-personality
2] https://www.indiatimes.com/lifestyle/self/what-do-the-first-letters-of-your-name-say-about-your-personality-278075.html
3] https://www.crio.do/blog/what-is-an-api/?utm_source=blog-int
4] https://towardsdatascience.com/launch-your-own-rest-api-using-flask-python-in-7-minutes-c4373eb34239
5] https://nordicapis.com/how-to-create-an-api-using-the-flask-framework/