1
0
mirror of https://github.com/creyD/asiimov.git synced 2026-06-12 00:52: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

View File

@@ -4,6 +4,7 @@ from django.contrib.auth.models import User
# For catching the save method for keeping user objects in sync
from django.db.models.signals import post_save
from django.dispatch import receiver
from .steam_api import getUserInfo
# CHOICE HELPERS
BADGE_RARITIES = [

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

View File

@@ -1,5 +1,5 @@
{% extends 'master.html' %}
{% block content %}
TESt
<h1>About</h1>
{% endblock %}