Reverse Engineering the AFL API
Why?
I love AFL and I have wanted to work with the data that the AFL puts out.
What am I doing here?
I am not sure yet. I have at least found that there are 2 different API endpoints that are used on the AFL Website.
- api.afl.com.au
- aflapi.afl.com.au
At the very least aflapi.afl.com.au is used to pull the entire season info and it seems a lot of content and high level stuff whereas api.afl.com.au is used for everything else.
My first idea here was to create a discord bot for game starts and other info but obviously I can't be polling the AFL website for any goals or realtime stats (quarters, game ends, tipping etc.).
I still don't really know what I am going to do with this but I have at least gotten a first call getting json of the entire AFL 2026 season.
import requests
import json
params = {
'pageSize' : 300,
'competitionId' : 1,
'compSeasonId' : 85
}
result = requests.get("https://aflapi.afl.com.au/afl/v2/matches", params)
with open("season.json", "w") as jsonFile:
jsonFile.write(json.dumps(result.json(), indent=2))
This spits out a full json file of the season that will obviously need to be further sanitised.
I wouldn't mind just dumping this into a SQLite or MySQL db to then setup further applications to hit it.
Looking into what happens when you load the fixture tab. First it hits the broadcast endpoint. aflapi.afl.com.au/broadcasting/event which then pulls all of the broadcasters for each game. Only 54 get pulled from todays date (21/2).
We get a bunch of other unimportant stuff then get to aflapi.afl.com.au/afl/v2/competitions/1/compseasons (1 being the AFL competition ID) with a page size of 15.
Then it grabs matches and further.
Finally, it gets to the all important to the AFL endpoint api.afl.com.au/cfs/afl/wagering. Giving them the odds for all the games that are live.
VERY IMPORTANT STUFF.
I will probably dig a bit deeper into this once I work out what I want to do with it.