# Steam Relationships ## A tool to discover friend relationships between steam profiles Ever ran into a cheater, looked at their profile, and realized all their friends are cheaters too? I have, and this tool is a way to measure degrees of separation from a specific individual Steam Relationships querries the Steam WebAPI to get public friends lists, and then recursively search those friend lists as well. This process repeats until a certain number of "degrees" have been met (a set recursion level specified by the user). The results of these querries are put in a database that can then be shared and used for other purposes ## REQUIREMENTS 1. Python 3.10 or greater 2. [Requests](https://docs.python-requests.org/en/latest/index.html) 2.31.0 or greater 3. A [Steam Developer API key](https://steamcommunity.com/dev/apikey) If using [Poetry](https://python-poetry.org/), all Python dependencies are fetched automatically ## INSTALLATION ### Pip version 1. Run `pip install steamrelationships` ### Poetry Version 1. In a poetry shell, run `poetry add steamrelationships` 2. Import the package `import steamrelationships` 3. Create an object (example: `steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")`) 4. Do a scan (example: `results = steamuser.basic_scan("XXXXXXXXXXXXXXXXX")`) Example: ```python #!/usr/bin/env -S python3 -i # A program that finds the friendliest person in a user's extended friend's list (1 recursive scan) import steamrelationships if __name__ == "__main__": rq = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", reqsafetybuffer=0.01) testlist = rq.recursivescan("XXXXXXXXXXXXXXXXX", recurselevel=1) del rq friendliest: str = "" mostfriends: int = 0 for person in testlist: if len(testlist[person]) >= mostfriends: mostfriends = len(testlist[person]) friendliest = person print(f"Largest friends list: {mostfriends}, Owned by: {friendliest}") ``` ## DOCUMENTATION ```python ''' CONSTANTS: Define a constants object: from steamrelationships.constants import _Const CONST = _Const() CONST.STEAMAPI_MAXREQ = 100000 # Steam's daily API request limit CONST.DAY_IN_NANO = (8.64 * (10 ** 13)) # The number of nanoseconds in a day CONST.JSON_INDENT = 4 # The indent used when dumping a python object to json ''' # Example import time from steamrelationships.constants import _Const CONST = _Const() checktime = time.time_ns() oldtime = int(input("Enter a time since the Unix Epoch in nanoseconds: ")) if checktime - oldtime > CONST.DAY_IN_NANO: print("It has been at least 1 day since the entered time") ''' STEAMRELATIONSHIPS: Create a SteamRelationships object: import steamrelationships steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") basicscan - do a basic scan of someone's steam friends PARAMS: (str) steamid64 - The 64 bit steam id of the user you want to scan RETURN VALUES: (dict) EMPTY - There was an error scanning the user's friends list (dict) {steamid64: [friendID1, friendID2, ...]} - A dict with a single key, that of the scanned user, which maps to a list of the users's friends recursivescan - Scan a user's friends list, then scan their friends as well PARAMS: (str) steamid64 - The starting user to scan (int) recurselevel - The number of recursive scans to complete > Note: 0 is equivalent to a basic scan; 1 scans the specified user, then the user's friends; etc. RETURN VALUES: (dict) EMPTY - Some catastrophic error has occured and no scan could be started (dict) { steamid64: [friend1id, friend2id, friend3id, ...], friend1id: [other_friend, other_friend, ...], friend2id: [other_friend, other_friend, ...], friend3id: [other_friend, other_friend, ...], ... } - A dict containing the starting steamid, then the friends contained in the original scan with the results of their scan NOTE: Please do not use a value greater than 3. While theoretically any value works, due to the exponential nature of friendship relations, you will very quickly spam Steam with tens of thousands of requests. If this concept is unfamiliar to you, please take a quick glance at the Wikipedia page for "six degress of separation": https://en.wikipedia.org/wiki/Six_degrees_of_separation TLDR: recursivescan is exponential and you will reach 100,000 requests very quickly if you recurse greater than 3 ''' # Example import steamrelationships steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") bigscan: dict = steamuser.recursivescan("XXXXXXXXXXXXXXXXX") littlescan: dict = steamuser.basicscan("XXXXXXXXXXXXXXXXX") del steamuser print(f'Original scanned user: {list(littlescan.keys())[0]}\nOriginal Friends: {littlescan[list(littlescan.keys())[0]]}') totalscanned: int = 0 alreadyscanned: list = [] for scanned in bigscan.keys(): totalscanned += 1 alreadyscanned.append(scanned) for friend in bigscan[scanned]: if friend not in alreadyscanned: totalscanned += 1 alreadyscanned.append(friend) print(f"Total scanned: {totalscanned}") ```