What I Knew About API’s, My Pre-Journey

Jasonajordan
Nov 9, 2020 · 5 min read

For a quite a while I was interested in software development but only until recently look a large step into making it my career. I did this by signing up for Flatiron’s Software Engineering Bootcamp! It is only week 3 and I’m learning so much already. We touched on API’s which is cool because I know a little bit about them before attending Flatiron. An API I personally worked with before is the Steam Web API with JavaScript. Steam is a software made my Valve Corporation, which is primary used as a virtual videogame storefront. Anywho, let me talk about API’s briefly walk you through a short tutorial on how to use an access the Steam Web API.

Image for post
A neat image of the Steam logo with game splash artworks in the background.

API stands for Application Programming Interface, which is typically used to have two applications talk with each other. API’s will most commonly come in JSON (JavaScript Object Notation) format which unfortunately looks a bit ugly to the human eye, but that’s okay because these files are meant not for human eye but computers to process information back and forth. These JSON files are kind of like a blueprint or a information guide for the program. For example below is the JSON data for my steam account. It looks ugly but there are some fun pieces of information in there.

{"response":{"players":[{"steamid":"768561198018634490","communityvisibilitystate":3,"profilestate":1,"personaname":"Resicallie","profileurl":"https://steamcommunity.com/id/resicallie/","avatar":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/07/07cf16b1d19e64f609000b1e9e3edc00df1fe4f8.jpg","avatarmedium":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/07/07cf16b1d19e64f609000b1e9e3edc00df1fe4f8_medium.jpg","avatarfull":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/07/07cf16b1d19e64f609000b1e9e3edc00df1fe4f8_full.jpg","avatarhash":"07cf16b1d19e64f609000b1e9e3edc00df1fe4f8","lastlogoff":1603668832,"personastate":0,"realname":"Jason Akira Jordan","primaryclanid":"103582791429696625","timecreated":1261739726,"personastateflags":0,"loccountrycode":"US","locstatecode":"NY"}]}}

Wow! this looks ugly, but that’s okay because we can tell what information has given to us. Javascript Objects are formatted with {key: value} We can pick out some fun pieces of information such as “timecreated” which gives us “1261739726”. But wait a minute you might say that’s not a time, it’s just a number. Well turn it is just a number however that number is actually the amount of seconds that passed since Midnight of January 1 1970, or called the Epoch Timestamp. Why that date, I honestly don’t know but it does have to do with the history of Javascript, and Unix Time which is above the level of computer science history knowledge. We can use this number to find out when I made my steam account.

I use a free Convert epoch timestamp to date to plugged in “1261739726” here are my results.

Image for post
Image for post
(https://www.freeformatter.com/epoch-timestamp-to-date-converter.html)

Wow, December 25th 2009. I remember this day my brother got me the orange box bundle for the PC so I could play Team Fortress 2! It was also 6 am so you knew I was pretty pumped for this. That was pretty cool. Now that I showed what you can do with API’s I should show you how to access this one.

There are a lot of information you can get using API’s. To access Steam’s APIs one can go to https://steamcommunity.com/dev/ and fill out the API request form shown in the picture below. Not all the API need a key however some do. You can check out the whole list of API’s on steam’s developer site. https://developer.valvesoftware.com/wiki/Steam_Web_API

As you can see there are a few different API already listened but for now I will go in a bit more depth of “ISteamUserStats:” This will take you to the page with gives instructions to many different stats such as Global Achievements Percentages, Global Game Stats, Player Summaries, Friend List, Induvial Player Achievements, Games Owned, and many more. Let’s check out Global Achievements…

Image for post
Image for post
The game TF2, I have a stupid amount of hours clocked into it.

The Global Achievements API gives the global percentage of people who completed each achievement in a game. We can check out Team Fortress 2’s Global Percentage with the link http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=440

The last part of the HTTP url “?gameid=” is used to pick out which game, Team Fortress 2’s ID being 440. Which means when you slap on 440 you get the API for Team Fortress 2’s Global Achievements. This is great and all but TF2 has a lot of achievements, 520 in fact, there is no way any sane person would look though that data and cherry pick what they are looking for. Which is why programing comes into play.

Image for post
Image for post
A standard fetchData function on JavaScript

This here is a good boilerplate fetchData function written in JavaScript (my first programing language I really tried to learn and develop skill wise). This is great, the first step of getting the JSON is done. Now we need to decipher the JSON file and make it useable to us. For example say that I would want to get just the amount of achievements in a game, we would take have to look for the ‘achievements’ keys and count the amount the length of it. As you can see TF2 being a super old game with many update has a huge number of achievements, 520. I actually don’t know any other game that would come close.

Image for post
Image for post
A very basic function to get the number of achievements.

As you can see API allow programs to get a lot of information however it’s key that we build the proper code that would allow us to sort through and pull the data. Somethings you can do on your own is make a program that prints each achievement and the percentage of people who completed it, or get the amount of hours a user might play a game for. There is a lot to do.

Anyway I would like to take the time to shout out to my favorite apartment mate Fade, who told me about a humblebundle package which had a javascript tutorial by Zenva which gave me a small taste into the development world. Without that I won’t have came across this.

The Startup

Medium's largest active publication, followed by +752K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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