Eason Li

How I Created A Simple Python API For Generating Random Word

Context

I created a simple Python API that generates a random word upon request. This project was inspired by Fireship’s Node.js API video. I simply created this API for fun, not as a side hustle, and I made the API open-source on my GitHub page.

Creating the API

First, I searched YouTube and found a video about creating a simple API using Flask. I watched the video and followed along. Then, I asked ChatGPT to generate a list of words ordered alphabetically (A-Z). Next, I created a Python variable to store the list of words. Finally, I replaced the emoji used in the video with the variable.

Deployment

It was time to deploy the API. I needed a free hosting option. I found some free choices like Cyclic.sh, but I ended up using PythonAnywhere.com because it’s free and easy to use. I created an account, uploaded the code to the server, uploaded my code to GitHub, and wrote a README.md file to explain how to use the API. And that’s it! I created a simple Python API for generating random words!

Here is the link to the GitHub repository

Thanks for Reading!

This blog post is writtin by Eason and edited by Google Bard.