Skip to content

Instantly share code, notes, and snippets.

@hannahherbig
Created November 16, 2016 02:54
Show Gist options
  • Save hannahherbig/bef2e946dd5ab9dfb489cfb366ae2442 to your computer and use it in GitHub Desktop.
Save hannahherbig/bef2e946dd5ab9dfb489cfb366ae2442 to your computer and use it in GitHub Desktop.
import requests
import time
class API:
def __init__(self, key):
self.key = key
def get(self, path, **args):
if path == 'replay':
time.sleep(6)
print('%s %s' % (path, ' '.join('%s=%s' % (k, v) for k, v in args.items())))
args.setdefault('k', self.key)
r = requests.get('https://osu.ppy.sh/api/get_%s' % path, params=args)
return r.json()
__call__ = get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment