Calculate the Soccer Pythagorean from your browser

A few days ago we pushed some updates to the web service that supplies match result data to our ResultsPage app, and we’d like to share one of these new features to you.

As you know, ResultsPage calculates various types of league tables on a round-by-round basis, one of them being the Pythagorean table. We’ve isolated the code that calculates the Pythagorean expectation and we now expose it to the outside world as its own API call.

In case you don’t know what I’m talking about, API is short for Application Programming Interface, and it is a collection of programming instructions that allow applications to talk to each other.  It provides a means to access and interact with data and information from multiple sources in an automated and creative way.

Programs interact with APIs in a variety of ways.  Some pass chunks of XML data back and forth.  We decided to design our API on REST principles.  The specifics aren’t that important — what is important is that you can access the Soccer Pythagorean through a URL address.

So here’s the Soccer Pythagorean API call:

http://fmrdlight.herokuapp.com/analytics/pythagorean?matches=XX&scored=XX&allowed=XX

All you have to do is add numbers where the XXs are for number of matches played, goals scored and allowed. That’s it.

What do you get in return?  Here’s an example:

http://fmrdlight.herokuapp.com/analytics/pythagorean?matches=24&scored=50&allowed=25

returns the following:

{
    "points": 47,
    "match": 24,
    "loss": 5,
    "allowed": 25,
    "win": 14,
    "draw": 5,
    "scored": 50
}

The expected point total is in the “points” field, while “win”, “draw”, and “loss” express on possible league record that would result in that point total (calculated from win/draw probabilities).

Now all of this is work in progress, so it’s likely that the URL root (fmrdlight.herokuapp.com) will change as the API matures.  For now, it’s an open API, so don’t be a jerk.  We’ll add some helper functions for those who don’t want to type a URL into a browser. We can create one in Python; maybe others can create their own.

So play around with the Pythagorean API. We hope this feature encourages its wider use in the football analytics community.

Share

Tags: ,