SteamAPI.py 1.1 KB

1234567891011121314151617181920212223242526
  1. import requests
  2. import json
  3. SteamUN = "Marorin"
  4. # steamID = SteamIDpulling(SteamUN)
  5. key = '231E98D442E52B87110816C3D5114A1D'
  6. def gamespulling(steamID,key):
  7. # Returns the XML data from the Steam API based of one's Steam ID number and returns a dictionary of gameids and minutes played.
  8. steaminfo = {'key': key, 'steamid': steamID,'format':'JSON','include_appinfo':'1'}
  9. r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/',params=steaminfo)
  10. d = json.loads(r.content)
  11. # print d['response']['games']
  12. # print r.json()
  13. return d['response']['games']
  14. def steamIDpulling(SteamUN,key):
  15. #Pulls out and returns the steam id number for use in steam queries.
  16. steaminfo = {'key': key,'vanityurl': SteamUN}
  17. a = requests.get('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/',params=steaminfo)
  18. k = json.loads(a.content)
  19. SteamID = k['response']['steamid']
  20. print SteamID
  21. return SteamID
  22. # steampulling(steamID)
  23. steamID = steamIDpulling(SteamUN, key)
  24. gamespulling(steamID,key)