My First CLI Project
At the end of Mod 1, I had to build a Command-line interface program. I also had to incorporate an API to get external data for the user to get. I decided to work with Ergast Developer API’s F1 API. This API has information for every Formula One season and session that was ever run. For this program, I wanted to output every year a World Championship was held, every circuit that an official F1 event was hosted at, and to return all the circuits in a year of the user’s choice.
The main thing I loved about building this project, was working with an API. I loved the different ways to manipulate the raw data to get different things. I used 3 different routes to get different information. By routes, I mean I filtered to get “f1/seasons”, “f1/circuits”, and “f1/#{useryear}”. The hardest thing was trying to get the specific information from the hashes that the data was stored in. In my API, the information I wanted, I had to go 3 or 4 layers into it to get what i wanted. Here is what the hash looks like.

To get what I wanted, I iterated until the key of the hash is where I go deeper into the hash, then saved that key’s values into a new variable.

This would give me the hash that starts with “circuitId” => “adelaid” in the first picture or similar info for other data. When I got this hash, I would send it to the class where I then strip it down more to get only the “circuit name” for this particular class. I would then save it, and have it on standby for when the user wants to access it.
When I output the data to the user, I first sorted the information in alphabetical order, then the data gets sent out to the user in a numbered list.
I was more than happy with how the project turned out, and would be excited to have the opportunity to work with an API again. If you want to see the project for yourself, here’s a link to it here: https://github.com/JakeKViti/f1-cli-project