MLB Pick’em on Ignition via Free MLB API
Please let there be no misunderstanding that Bill is the mad scientist that figured out how to use an under-documented API and pull it into a brand new Ignition 8.0 Vision client. He deserves all the credit for this one!
The only thing Corso may love more than Ignition is creating crazy applications in it so I was only half joking when I proposed we do a pick-em league for MLB like we have with the NFL and NCAA. It’s only 2,430 regular season games, after all!
We quickly settled on a saner way to play. Everybody picks one team from each division and earns points for that team winning throughout the season. Easy!
Since it was only a couple of days before opening day when we decided to make this game a reality, I turned to my tried-and-true development environment to make it happen.
Vision in Ignition 8.0
At its core, not much has changed with Vision in Ignition 8.0. It’s the same drag and drop WYSIWYG editor we know and love. However, the individual components got a major facelift. I didn’t have to change a single foreground or background color, font or border to arrive at great looking screens with a flat look and high-performance feel.
The designer also benefited from the same overhaul. The neutral backgrounds and sparse use of color work together to highlight the important areas of the Vision work space, which has been given its own entry in the project browser with the addition of the Perspective module.
The bulk of the work was creating and populating the database tables. We’re keeping a record of each team with a reference to their league, division, the team’s unique identifier in the MLB API and the image path for the team logo. With just a quick template and a simple query to populate a template repeater from the database, we have everything we need for visualization.
MLB exposes a ton of live and historical data in its stats API. Although the API is free and open to the public, there seems to be no official documentation at this time. What I’ve gathered, is that MLB has transitioned from an XML style repository to a new JSON based implementation. Luckily, dedicated users of the old API have figured out how to use the new implementation and have shared their findings online.
Knowing the base URL, you can pass in a date or date range to get a list of scheduled games and the results. I implemented a Python script to do this every morning to check the previous days games and update each user’s score in the database.
Want to know more about Corso’s games? Check out our NCAA and NFL Pick’em posts (which we apparently need to do a better job documenting).
Want to see more Ignition 8.0 and Perspective information? Check out our Rolling Updates page!