-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
28 lines (24 loc) · 880 Bytes
/
examples.py
File metadata and controls
28 lines (24 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import requests
from dotenv import load_dotenv
load_dotenv()
BASE_URL = os.getenv('CITO_BASE_URL', 'https://api.citoapi.com/api/v1')
API_KEY = os.getenv('CITO_API_KEY')
def cito(path):
if not API_KEY:
raise RuntimeError('Missing CITO_API_KEY. Get a free key: https://citoapi.com/signup?utm_source=github&utm_medium=starter_repo')
res = requests.get(f'{BASE_URL}{path}', headers={'X-API-Key': API_KEY}, timeout=20)
res.raise_for_status()
return res.json()
examples = {
'LoL live': '/lol/live',
'CDL upcoming': '/cod/matches/upcoming',
'Dota 2 live': '/dota2/matches/live',
'UFC rankings': '/ufc/rankings',
'Fortnite item shop': '/fortnite/item-shop',
'Apex ALGS': '/apex/algs/matches/upcoming',
}
for label, path in examples.items():
print(f'\n## {label}: {path}')
data = cito(path)
print(str(data)[:1000])