Squiggle API

v1.3.0

About

The Squiggle API offers public access to raw data about AFL games and predictions made by popular online models. It is available in computer-friendly formats so you can automatically import it into a spreadsheet or similar program for your own analysis.

Selecting Data

Query Type

You must supply one of these values as the parameter "q":

gamesInfo about games (e.g. Round 1, 2019 Richmond v Carlton)
standingsInfo about team standings, including the actual ladder
sourcesInfo about models (e.g. Matter of Stats, GRAFT, Swinburne)
teamsInfo about teams (e.g. Richmond, Geelong, West Coast)
tipsInfo about tips and predictions made by models
ladderInfo about predicted ladders generated by models

Examples:

Format (optional)

You may specify a preferred output format:

JSONJSON format (default)
XMLXML format
CSVComma-separated values

Examples:

Extra Parameters (optional)

You may specify any number of the following parameters:

yearYear
roundRound
gameGame ID
sourceSource ID
completePercent of game completed, where 0 means the game hasn't started and 100 means it has finished

Examples:

To exclude a particular value for a parameter, prefix it with "!".

Examples:

Default behavior when parameters aren't specified (e.g. requesting "?q=games" with no "year=xxxx" parameter) is undefined and subject to change. For example, at present, "?q=games" returns data on all games, but in the future, it may default to the current year instead. For reliability, supply parameters in your request to identify the data you want.

Using Data

Google Sheets

To automatically import data into Google Sheets, enter a formula like this into a cell:

	=IMPORTXML("https://api.squiggle.com.au/?q=tips;year=2018;source=1;format=xml", "/*/*")
	

... wait a second and bam! Data appears.

Microsoft Excel

I believe you can do the same thing in Excel, although I don't own a copy so can't test. From what I've read, in newer versions you do: DataGet & TransformFrom FileFrom JSON and then can enter an URL (like https://api.squiggle.com.au/?q=tips;year=2018;source=1).

Excel can read JSON, XML, and CSV, so it shouldn't matter which you choose, so long as the URL matches the function. (That is, if you click "From JSON", don't give it an URL with ";format=xml".)

LibreOffice Calc

Use SheetLink to External Data and paste in the appropriate URL (like https://api.squiggle.com.au/?q=teams;format=csv). You may need to specify XML or CSV format (not JSON).

Automated Usage

People often write data-fetching scripts and bots without adequate testing or consideration of failure conditions. This leads to bots that spiral out of control and make hundreds (or thousands!) of simultaneous requests for data — often the exact same data, over and over — which is a waste of everybody's resources.

If you set your script/bot's UserAgent to something informative, I can contact you if this happens and explain the problem. If you don't, all I can do is deny the bot service. So if you're seeing a block message, that's why.

Please write a well-behaved bot!

  1. Set the UserAgent to something that identifies it and provides a way to contact you.
  2. Cache the data you get, rather than repeatedly fetching it. (I am looking right now at a bot that is fetching the names of AFL teams multiple times per second, and another that asks the API every 9 seconds for every piece of data it has on everything.)
  3. Avoid making large numbers of simultaneous requests.
  4. Avoid fetching more data than you need.

Changelog

June 20191.3.0Added standings for generating actual ladder at a point in time
June 20191.2.0Added support for output as comma-separated values (CSV)
May 20191.1.0Added ladder for outputting ladder predictions
April 20181.0.0Original version

Max Barry

squiggle.com.au

twitter.com/squiggleAFL