Creating a github contributions api
I like to build stuff in minecraft to unwind. There’s a mod called opencomputers that allows you to hook things up to the internet, and I thought it’d be neat if I could get the minecrafty looking github status page to actually show up in minecraft:
I assumed the data needed to generate that calendar was easily available via the api, but unfortunately it’s not. I might have been able to generate the data necessary by traversing through a user’s commit history and tallying up the results, but that seemed inefficient, even if I were to get all the data in one request with their graphql api. Instead, I opted to just scrape the profile page. The page is quite well formatted and doesn’t get style changes very often, so it should be fairly stable. It also seems like the only way to access contribution activity for private repos if a user has publicized private contributions.
Once I was sucessfully scraping and formatting the contribution calendar into json, I created a little api for requesting a user’s contribution history. Documentation and other information can be found on github. Now I was all set up to bridge the gap and get it into minecraft!
It took a bit more work to render the chart in minecraft than to parse the data from the page. I needed to create some code to combine two holograms (the hologram is a neat 3D display device from opencomputers, but one wasn’t big enough to display the data), render text, render a calendar, and fill in some dates on that calendar. Once that was complete, it was just a matter of hooking it up to the github contributions api created earlier: