Designing API Behavior With Code
I recently shared how a team I worked on designed an API using code. The goal was to show that code can be used as a tool for design, and how prototyping can give us fast feedback on the quality of our design.
In this writeup we’ll look at how we might use code to design API behavior. We’ll use Python and FastAPI like we did in the last writeup, so you may want to read it first before moving forward.
API Design First by Writing Code First
I was on a team that needed to design a new API. As a Design First team, we’d normally start off with an OpenAPI file. But this time we started with some code. We opened up our IDE, created a Python file, and started coding models and endpoints.
It might seem like we switched to a Code First approach since we started with code. But this wasn’t the case for us.
Solving FizzBuzz With Hypermedia
I had some free time this last week and I decided to try to solve FizzBuzz with hypermedia. I thought I’d use it to show some of the benefits of using hypermedia, along with some of the downfalls of not using it.
First, What is FizzBuzz? If you’re not familiar with FizzBuzz, here is the idea behind it (source):
Write a program that prints the numbers from 1 to 100.