Finding Discounted Video Games Using Python and APIs.

Aziz Vohra
INST414: Data Science Techniques
4 min readDec 11, 2023
Image From: https://www.nexsoftsys.com/articles/why-gaming-industry-is-moving-on-to-python.html

Introduction

Have you ever had nostalgia hit you so hard that you found yourself remembering playthroughs of old video games you used to play? Especially if it reminds you of a video game from a particular time in your childhood or your favorite movie tie-in game. Sometimes wanting to play an old game or for those that are diving back into gaming want to spend the least amount of money to purchase a game. Video games are constantly going on sale for various reasons, this could be because of profits regarding the company or another sequel installment of the original game. Whatever the case may be, I believe everyone loves a good sale and what better way of doing that than by using Python and APIs.

Insights

I wanted to develop a program for a user to search for a video game they want and list all the possible prices along with the stores that are offering them. Searching for video game prices is already hard enough and finding a good deal on one is even harder. Some websites are pushed to the top of the results page resulting in users finding the game on other websites where the price may be greater or equal to the retail price. This shrinks the domain of countless other websites that may be selling the game for cheaper. I believe the data needed to solve this problem lives through the internet and APIs and is important especially if we want to find sweet deals for games we love!

Data Collection

I collected the data through an awesome API called CheapShark API and by using the requests library in python, I was able to extract data that was in json format and access the values I needed to display. The API documentation was very easy to follow and showed many helpful tips in collecting the data. I collected data and parsed through three different GET API calls so it would be possible to find a game based on the users search, and extracting values such as the retail price of the game along with the current price and gameID.

A function where it takes the users title search and uses it as an endpoint in the url to find the game.

Data Analysis

While working on the API and trying to parse the json data, I was intrigued to learn all the many ways this data could be used especially for showing graphs of which stores have the game at the lowest price. Though this was intriguing I decided on using the terminal to output most of the deals the user would be interested in.

Data Cleaning

To clean the data that I was extracting was very satisfying and helped me understand more on how json data and how the many key and value pairs worked together. Every call I make to the API has a response and within this response gets tricky.

Portion of a function where the responses are assigned to a variable for easier use in

Every response I get, I make sure to print it out and see where I am currently within the data and where I have to go to access specific keys and values. One of the most common mistakes I was making when trying to get specific parts of the json was not accessing it correctly in the response.

Continuation of the function above that shows nested for loops checking for validation of the storeID and storeName and appending and returning the results as a tuple.

Another part where I found myself struggling was validating the ‘storeID’ values from both API calls and assigning the specific storeID with its storeName. I found the solution however by realizing that each of these calls can be nested inside the for loops. This helped with iterating through the gameID’s and prices.

Limitations/Discussion

This API and its provided documentation were created by its incredible and respected creators over at CheapShark. Just like with all data there is always limitations and I believe a discussion for this is important to remember how we can use this data in the future. I believe some limitations to this would have the be some drawbacks on my part with edge cases within the my code. These can be easily fixed with cleaning the terminal and starting the program again.

Code for this below.

Github Repository: https://github.com/Avohra980/414Assignments/tree/main/assignment1

--

--