Kotangent

Antonio, a Board Game Geek trading tool

by Brian Koser

I’ve decommissioned Antonio, it was really only used briefly. You can still access the repository at Github.

If you’re into designer board games (you should be!) and you’re online (…you are!), then you’re probably aware of BoardGameGeek, which is the board game website, where aficionados discuss, trade, and celebrate all things board gaming.

Recently, a fellow named Scott Jaworski asked if there’s a way to find a list of board games he could get in a trade if he traded one of his away. BGG doesn’t support this functionality, and it sounded like an interesting and easy project, so I went ahead and did it. Meet Antonio. Here’s how he was formed:

Most of the necessary data is availalbe from the BGG API. Rather than using the official BGG XML API directly, I decided to use E. Strathmeyer’s JSON API, which is built upon the former. I considered a different JSON API, but it was down when I started coding. Maybe next time.

One item not provided is the list of users that want to trade for a game. So, I wrote my own API. Having never written a web API service, I started researching technologies. The best option looked to be an ASP.NET Web API, so I read some of the Microsoft tutorials and got started. The API itself was surprisingly easy to set up, as was deploying to Azure. I used HTMLAgilityPack and Fizzler, which made screen scraping easier than expected. In fact, while I expected this to be the most difficult piece of the puzzle, it turned out to be one of the easiest.

I did get tripped up by CORS, cross-origin resource sharing. This had to be enabled so I could call my API from a web page. Once I identified the problem it was not difficult to fix.

Next I set up a simple web page, grabbed jQuery, and started writing the client-side portion of Antonio. This portion took the most time, and had some challenges of it’s own, a couple of which were solved by new-to-me features: the apply function and promises.

One disappointment was that, while you can get the games a user wants to trade from BGG’s API, you can’t get it on demand. The data has to be generated, which in my experience takes up to 24 hours. My solution was to display a list of users whose data is being generated, but it’s annoying that a user could type a game into Antonio and then have to wait until the next day, come back to the page and search for the game again. Oh well.

Antonio was a fun project to write, and I learned a good bit about .NET and JavaScript to boot. Check it out, and let me know if you have any questions about anything. You can see all the code at Github. If you experience problems, you can contact me, open an issue on the Github project, or reply to my post about Antonio on BGG. ∎