Can You API an Entire League?

How to Set an API Class

To start my project, I had to set up an API class in order to allow my project to interact with my selected API. An API is a way that a company can make their data accessible for other programmers to use. The comparison I’ve seen used frequently is that an API is something like a menu at a restaurant. You have a list of dishes, some information about that dish, and you have somebody else do the work to get you that dish.

Some of the code used in my API class.
Some of the code used in my API class.
Image from the API as seen in Google Chrome.
Image from API in Google Chrome after using Chrome’s JSONView extension.

Finding My Rivals

The part of my CLI that gave me my biggest headache was at the very end of my program. I wanted my program to take in the team a user wanted to look at, find the division that team plays in, and return the other teams in that division. Here’s the code that ended up working for me:


Since this was my first experience with really building out a full program from scratch, without an environment given to me through tests, it started out as an incredibly daunting task. APIs can be scary to confront, the wall of text that they give you at first glance can seem pretty menacing. After getting the ball rolling, this was a very fun challenge. Even with the problem solving and critical thinking skills the previous 3 weeks had given me in regards to coding, it’s fun to come out of this project with those skills developed even further. Even more than before, I’m looking forward to the next challenge!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store