In [1]:
import requests
import yaml

This is a work in progress to add the latest competitions semi-automatically. TODO:

  • [ ] Concat metrics + unique
  • [ ] Add categories
  • [ ] Add solutions missing solutions

In [3]:
COMPETITIONS_PATH = './competitions.yaml'
with open(COMPETITIONS_PATH, 'r') as f:
    saved_competitions = yaml.load(f)

In [4]:
i = 0
all_competitions = []
while True:
    base_url = 'https://www.kaggle.com/competitions.json?sortBy=latestDeadline&group=general&page={}&pageSize=20&category=featured'.format(i)
    i += 1

    r = requests.get(base_url)
    competitions = r.json()['pagedCompetitionGroup']['competitions']
    all_competitions += competitions
    if len(competitions) == 0:
        break


0
1
2
3
4
5
6
7
8
9
10

In [14]:
with open(COMPETITIONS_PATH, 'w') as f:
    yaml.dump(saved_competitions, f, default_flow_style=False)

In [ ]:
keys = ['competitionId', 'competitionName', 'competitionTitle', 'competitionDescription', 'competitionUrl', 'coverImageUrl', 'thumbnailImageUrl', 'deadline', 
        'rewardQuantity', 'rewardTypeName', 'organizationName', 'organizationUrl', 'organizationAvatarUrl', 'hostSegment',  'evaluationMetric',]

to_print = []
for competition in competitions:
    to_print.append({k:competition[k] for k in keys})
print(yaml.safe_dump(to_print, default_flow_style=False))