steam.py 982 B

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