API’s and Armchair Populism

Ben Stephanus
3 min readMar 8, 2021

This is a little story about my CLI project for the conclusion of my Phase 1 study for Flatiron School’s part time software engineering program. Truth be told this my second attempt in this program, and it was right before this very same spot that I gave up the first round. Well, “gave up” is a bit dramatic, as I had some health concerns that needed to be taken care of, but amidst the stress of that, it was as if my mind just went blank. It was as if my cranium just wouldn’t allow any other data in. I my brain had an @@all class method, it could’ve used a .clear Ruby method if you catch my drift.

But that’s the thing about Phase 1; you’re thrown a lot of information at you and if you don’t have a background in tech, like myself, it’s easy to get lost. This time around however, has been a little bit easier. Flatiron starts with Procedural Ruby before taking a dive into Object Oriented Ruby which all leads to this, The CLI project.

CLI stands for Command Line Interface and it’s something we use every day. Any time you enter words into a search engine you’re using a command line. Lucky for me, the requirement wasn’t to invent another Google, but rather just a simple program where the user can enter some info, and then we retrieve data to deliver back to the user. We were given the option to either use Scraping, which is like operating on the Document Object Model (DOM), or to use something called an API. I chose the latter, hoping it would be a little more stable for my program rather than Scraping which depends on yesterdays code so to speak and unless the website you are scraping is completely static and never changes, things could get dicey.

API stands for Application Programming Interface and basically it provides an end point that contains data you can mine through. The end point is a URI (Uniform Resource Identifier), which is essentially a link. Using JSON (Java Script Object Notation), you can sort through a hash of the information you need and code your way into some fun stuff.

For my project I decided to create a simple program where a user can check a stock price. Inspired by the recent Game Stop Reddit story in the news, I thought it would be timely to check the GME stock. I did however, find that to not be general enough for what the project entails and did a little digging into how I could change that.

I was using an API for Yahoo Finance and I noticed that in the provided URI, there was a “symbol=GME” in the query string. In my API class in my code, I created a method that accepts a symbol as an argument, and replaced that symbol in the end point within the method. As an example, Tesla who’s symbol is TSLA, could get passed in and it would return Tesla’s stock price, incidentally which is trading much higher than Game Stock, poor guys. I then created a CLI class that retrieves information from the user, interacts with the API class that was previously mentioned to return what the user is looking for. Now everyone’s happy except for whomever runs Game Stop and wealthy hedge fund types who lost their shirts because some edge lords on Reddit were calling their bluff. Another group of “poor guys” whom I’m presuming aren’t so poor in reality.

In conclusion, I could explain the nuts and bolts of how an API operates about as well as the ins and outs of short trading on Wall Street, but I suppose the goal of this project was to get everything working, which I did and I’m proud of. That’s the thing about learning; there’s always more to take in before calling @@all.clear.

--

--