Skip to content

Instantly share code, notes, and snippets.

@woctezuma
Last active November 7, 2023 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woctezuma/6be1615fab1684c2dbcf4dba882184ca to your computer and use it in GitHub Desktop.
Save woctezuma/6be1615fab1684c2dbcf4dba882184ca to your computer and use it in GitHub Desktop.
# 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