The heat is on!
In Brazil, the Football World Cup 2014 started on June 12 with the opening match between Brazil and Croatia. The world’s media spins all kinds of news around the tournament, the games, the players, the spectators and fans. The world’s sports fans enjoy a rush of entertainment and excitement, happiness and disappointments, during a few busy mid-summer weeks.
Keep your own score
How about if you could keep your own, dynamic scoreboard, for you and your friends to enjoy? When you have put some effort to design a cool looking chart, you need dynamic data to fill it with. No problem, there are several useful APIs for feeding your scoreboard. A few examples:
- Kimonolabs provides the “(un)official World Cup API“, with extensive info and API documentation, down to the preferred foot for each player in every team.
- Web agency Kollegorna publishes dates and times for upcoming matches at www.vmidag.se, www.vmidag.no and www.vmidag.dk. They have a public API with a comprehensive JSON response.
- Everysport provides events, results, standings and team info in most sports league on their web site, and as an API for developers.
Not a programmer?
No worries, you can explore plenty of interesting stuff without programming a single line of code. Take a look at Kimonolabs’ World Cup Explorer, where you can play around with settings directly on their web site. For Everysport.com, there is a convenient tool, the API Console, which lets you explore the Everysport API response, even without your own API key.
And now, a little bit of coding
The API uses unique numbers to identify each sport, league, event, team etc. For our little test, we will use the endpoint “leagues” and fetch the “events” object by using a GET request from a PHP script. The response is in JSON format. Since Everysport.com is in Swedish, the national team names in the response will be in Swedish.
Of course, we are interested in the football World Cup league, or “fotbolls-VM” in Swedish. But to fetch events, we need to specify the exact group or play-off stage of the World Cup. We will use “Group A” as an example, and its ID is “64579.” To look up other IDs, just navigate Everysport.com to the correct page, and then the ID will be shown in the address field as the last digits of the URL.
To fetch information and current standings of all games in Group A, we use this URL string:
Steal with pride!
For your convenience, a very simple, working example is available on Github. It contains both a PHP script and an HTML file.
The output looks something like the image below. As you can see, it is far from the nicely formatted scoreboard you want. But the rest is up to you. Go ahead and use the code as inspiration and develop your own dynamic World Cup scoreboard.
Scorecard image credit: happyholidays2014