Last active
November 7, 2023 09:01
-
-
Save woctezuma/6be1615fab1684c2dbcf4dba882184ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My Napkin API to get a dict mapping Steam appIDs to app names | |
# | |
# References: | |
# [1] API host: https://www.napkin.io/ | |
# [2] Documentation by SteamDB: https://steamapi.xpaw.me/#ISteamApps/GetAppList | |
# [3] Personal API endpoint: cf. the title of this Github Gist | |
from napkin import response | |
import requests | |
print('ok') | |
def download_data(): | |
url = 'https://api.steampowered.com/ISteamApps/GetAppList/v2/' | |
r = requests.get(url) | |
if r.ok: | |
data = r.json() | |
else: | |
data = {} | |
try: | |
d = data['applist']['apps'] | |
except KeyError: | |
d = [] | |
return d | |
app_list = download_data() | |
expected_num_apps = len(app_list) | |
print(f'Expected #apps = {expected_num_apps}') | |
app_dict = { | |
app['appid']: app['name'] | |
for app in app_list | |
} | |
total_num_apps = len(app_dict) | |
print(f'Total #apps = {total_num_apps}') | |
response.status_code = 200 | |
response.body = app_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment