The other day I was chatting with some local gamers in our Slack group. The discussion centered around knowing what games each person had in their collections. After pasting in a link to my collection my friend Josh commented:
when you need the BGG api to tell you how many games you have
I was struck with the idea of using the BoardGameGeek API to do just that. Obviously I can just go to the website to find out my own games, or the games that another user owns. But what if I wanted to compare our collections, and find the games that both users own, or have in their wishlist, or have previously owned. So I took an hour or so and wrote up a quick script to do just that. So here’s a quick writeup on how you can compare the BoardGameGeek collections of any two users.
Disclaimer…I’m on a Mac and don’t have any way to test this on a Windows machine. The script is written in Python so it should work the same, but I can’t guarantee that.
Before you can run this script you need to make sure you have Python, and you’ll need to install the boardgamegeek API.
Do I Have Python?
Thankfully, finding out if you have Python is easy. Open up your Terminal and type
which python. If your computer returns a file path, then you’re golden.
Installing the boardgamegeek Library
If you already have Python then you likely have the means to install scripts from outside sources using a tool called Pip. Run the command
pip install boardgamegeek in your terminal, then see what happens. If that doesn’t work try running
If neither of those work, then you’re on your own. Google for it, then come back to this for the rest. I’ll wait…go ahead!
Running the Script
Copy the contents of the script at the bottom of this post, and save the file as
bgg_games.py, in whatever directory you like. The script accepts two required arguments: user_one, and user_two, and an optional argument of the type of games you want to compare:
Once you have those pieces of information you can call the script from the terminal like so:
python bgg_games.py <user_one> <user_two>
To include only games in both player’s wishlists
python bgg_games.py <user_one> <user_two> wishlist
To include only games in both player’s previously owned lists
python bgg_games.py <user_one> <user_two> prev_owned
For example, comparing the wishlist’s of my account and my friend Eli’s account would show this:
['El Grande', u'Orleans', 'Potion Explosion', 'San Juan (second edition)']
If an error of any sort occurs you’ll see a message stating
An error occurred, please try again.. If that happens, make sure the usernames are correct, and that you’re passing in the correct list type. If there’s still an error, feel free to message me on Twitter with questions.