deivit24 / python-steam-api

MIT License
25 stars 11 forks source link

Friends list limited #10

Closed ibksmqixopjadihe closed 10 months ago

ibksmqixopjadihe commented 10 months ago

When running the provided example to get a users friends list, the amount of friends is limited to about 100 results or will error out if it's too large. Try a steam user with a large friends list.

deivit24 commented 10 months ago

@ibksmqixopjadihe ohh I see. Sorry, do you mind providing an example of a user with a large friend list? Might have to paginate or add a parameter to increase max results

deivit24 commented 10 months ago

@ibksmqixopjadihe Can't find someone with a list longer than 100 lol I did find a friend with 79. So STEAM doesn't have documentation on what is the limit of the results.

They have an API where the parameter is the steamid and it returns a nasty nested object and from that, I can get a list of friends' steamids, then I loop through and call STEAMS get details API and some other transformation. I did a test looping around 200 IDs and it worked fine.

As far as the first API call, idk what is the limit. You can reopen the issue if you see it and I can look at it further!

LetsTwist commented 5 months ago

@deivit24 The problem is still relevant, by running this code:

from steam import Steam
from decouple import config

steamID64s = (
    76561198168593833,
    76561198286921942,
    76561198091790258,
    76561198317708731,
    76561198344148216,
    76561198086020371,
    76561198004414153,
    76561198104777635,
    76561198326192731,
    76561198281932001
    )

KEY = config("STEAM_API_KEY")
steam = Steam(KEY)
for counter, steamID64 in enumerate(steamID64s):
    print("[" + str(counter + 1) + "/" + str(len(steamID64s)) + "] " + str(steamID64), end=" ", flush=True)
    while True:
        try:
            player_friends = steam.users.get_user_friends_list(steamID64)
            break
        except Exception:
            pass
    print(str(len(player_friends["friends"])) + " friends")

i get this:

[1/10] 76561198168593833 100 friends [2/10] 76561198286921942 100 friends [3/10] 76561198091790258 100 friends [4/10] 76561198317708731 100 friends [5/10] 76561198344148216 100 friends [6/10] 76561198086020371 100 friends [7/10] 76561198004414153 100 friends [8/10] 76561198104777635 100 friends [9/10] 76561198326192731 100 friends [10/10] 76561198281932001 100 friends