1
0
mirror of https://github.com/creyD/asiimov.git synced 2026-06-13 09:32:23 +02:00

Added Steam API Queries

This commit is contained in:
2020-01-14 12:16:44 +01:00
parent 228417aeaa
commit 6005921568
3 changed files with 25 additions and 1 deletions

23
src/core/steam_api.py Normal file
View File

@@ -0,0 +1,23 @@
# For communication with the Steam API
import urllib.request
import json
# For getting the STEAM_API_KEY
from django.conf import settings
STEAM_SERVER = 'https://api.steampowered.com/'
USER_METHOD = 'ISteamUser/GetPlayerSummaries/v2'
INVENTORY_SERVER = 'https://steamcommunity.com/inventory/'
# Get the mandatory gamer info for a gamer
def getUserInfo(steamID, API_KEY=settings.STEAM_API_KEY):
QUERY = STEAM_SERVER + USER_METHOD + '/?key=' + str(API_KEY) + '&format=json&steamids=' + str(steamID)
player_object = json.load(urllib.request.urlopen(QUERY))
return player_object
# Get the CS:GO inventory of a gamer
def getUserInventory(steamID, API_KEY=settings.STEAM_API_KEY, GAME_ID=730):
QUERY = INVENTORY_SERVER + '/' + steamID + '/' + GAME_ID + '/2?l=english&count=5000'
inventory_object = json.load(urllib.request.urlopen(QUERY))
return inventory_object