Contest tools and workflow


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Using the API with Python

Now that we know how to use the API, let's send some requests with Python!

The following code will download a replay:


I recommend to save it to your disk before running a complex analysis. That way you don't have to download it multiple times when your analysis code is buggy at first.

Let's have a closer look at what we just downloaded: API_unauth On the left you see the online version, on the right our downloaded json. The errorstream is missing. We need to login first in order to get it too.

Let's try again, this time with login. This code is intentionally not embedded in a runner, as it needs your login information in order to work properly. It's just for reference and offline execution.

import os, json, requests, sys

email = ''
pw = 'YourSecretP4ssw0rd'
userID = 1500515 # that's my userID, you have to change it
game_id = 453253378

# the session object saves cookies
with requests.Session() as s:
    # let's login first
	p ='', json = [email, pw, True])
    # the same request as above, but with a session object
	r ='', json = [str(game_id), userID])
	replay = r.json()
	# TODO save your replay
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content