What is an Application Programming Interface (API)?

Application Programming Interface (API) is a generic term. For example, it may apply to everything from the diagnostic port under your car’s dashboard, to the physical switch on your blender that controls the rotational speed of the blade. Nothing about the term “API” need necessarily involve HTTP or databases. Therefore, if you ever get into a conference call regarding APIs, and don’t want to seem like a noob, valid questions include:

  • The proposed API will be implement what programming language and framework? Frameworks are libraries that abstract away some of the complexity behind accepting HTTP messages (GET, POST, PUT, DELETE, etc.), sending numeric responses and possible attachments.
  • What service is our API exposing? That’s a nice way of saying, “Why are we doing this?”
  • Will the API have a connection to a database? The project in this article uses session-cookies to maintain state on the client’s side. There are no database requirements to deploy the API Quest service.

Flask vs Django

In my own exploration of API and API design, I’ve taken a bit of a shine to the Python Flask library. That library is found at https://palletsprojects.com/p/flask/.

Flask takes the minimalist micro approach to API design. As in, if you want it, build it yourself. That works well for me. I’ve always been a firm believer that if you don’t need something, it doesn’t pay to carry it around with you. Additionally, last I checked, Flask is the most popular Pythonic API framework in the world, outpacing even Djanjo.

What’s Django? Django ( https://docs.djangoproject.com/en/3.0/ ) is the ‘batteries included’ approach to API design with Python. In this case, ‘batteries included’ is an attempt to provide you every design tool imaginable. It’s a bit daunting for newcomers, but check it out, they have a rather intense introduction that clocks in at a mere 7 pages: https://docs.djangoproject.com/en/3.0/intro/tutorial01/. Django will remain a popular solution for creating APIs, but in 2020, less is more.

API Quest: So, you want to be an API Python Hero?

Designing APIs with Flask is a learning opportunity that I have interwoven with my desire to design a simple role playing game (RPG). The passion for video games, along with a desire to learn Flask, is a clever way to keep me making gains. After a few false starts, I have >100+ design hours in API Quest.

API Quest: So, you want to be an API Python Hero?
Aye, what strange and magical times! The fates of mortals are determined not by 20 sided dice, but by the randomness of bits within a server.

The project source code for API Quest is maintained at: https://github.com/rzfeeser/api-quest

Within the repo root, you’ll find quick-start instructions within the README.md file. Once the Flask server is running, players can connect to the RPG API using their favorite web browser.

Overall Project Goals

Goals for this project include mastering the following concepts:

  • Flask – Pushing my understanding of API design with Flask. The Python Flask library: https://palletsprojects.com/p/flask/
  • Cookies – Learning to properly maintain and store state on a client via cookies and session-cookies.
  • Image Editing – The project should eventually offer some images to help the player navigate. This includes, maps, enemy avatars, shops, buildings, and terrain. I am a decent artist, but one goal is to improve my ability to use image tools, like Photoshop.
  • Git Branching – I want to more thoroughly understand the concepts behind git branching. Therefore, within this project, each branch is a stable release. The ‘master’ branch is always a match to the current ‘stable’ release. Finally, the ‘devel’ branch contains all current and on-going work.
  • Video Game Design – An incredible amount of planning and story writing is required before any code can get written. Learning the process of creating interactive stories is thrilling!

If you are new to Python, but interested in learning to use Python for API design, I would recommend reviewing the Python Lessons I have posed on my site. Some of those lessons include:

About me, Russell Zachary Feeser

Like what you read? I am always looking for the next training event to teach. If you’re a training coordinator looking for a Python, Ansible, or telecom subject matter expert (SME), reach out! I would very much enjoy heading your next training event. Use https://rzfeeser.com/contact/ , or my company site, https://iris7.com/, to get in touch.