diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 148 |
1 files changed, 139 insertions, 9 deletions
| @@ -8,18 +8,148 @@ Steam Relationships querries the Steam WebAPI to get public friends lists, and t | |||
| 8 | 8 | ||
| 9 | ## REQUIREMENTS | 9 | ## REQUIREMENTS |
| 10 | 10 | ||
| 11 | 1. A [Steam Developer API key](https://steamcommunity.com/dev/apikey) | 11 | 1. Python 3.10 or greater |
| 12 | 2. [Poetry](https://python-poetry.org/) | 12 | 2. [Requests](https://docs.python-requests.org/en/latest/index.html) 2.31.0 or greater |
| 13 | 3. A [Steam Developer API key](https://steamcommunity.com/dev/apikey) | ||
| 14 | |||
| 15 | If using [Poetry](https://python-poetry.org/), all Python dependencies are fetched automatically | ||
| 13 | 16 | ||
| 14 | ## INSTALLATION | 17 | ## INSTALLATION |
| 15 | 18 | ||
| 16 | 1. Clone the repo | 19 | ### Pip version |
| 17 | 2. [Install poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) (if poetry isn't already installed) | 20 | |
| 18 | 3. Open a `poetry shell` | 21 | 1. Run `pip install steamrelationships` |
| 19 | 4. Run `poetry install` | 22 | |
| 23 | ### Poetry Version | ||
| 24 | |||
| 25 | 1. In a poetry shell, run `poetry add steamrelationships` | ||
| 26 | 2. Import the package `import steamrelationships` | ||
| 27 | 3. Create an object (example: `steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")`) | ||
| 28 | 4. Do a scan (example: `results = steamuser.basic_scan("XXXXXXXXXXXXXXXXX")`) | ||
| 29 | |||
| 30 | Example: | ||
| 31 | |||
| 32 | ```python | ||
| 33 | #!/usr/bin/env -S python3 -i | ||
| 34 | |||
| 35 | # A program that finds the friendliest person in a user's extended friend's list (1 recursive scan) | ||
| 36 | |||
| 37 | import steamrelationships | ||
| 38 | |||
| 39 | if __name__ == "__main__": | ||
| 40 | rq = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", reqsafetybuffer=0.01) | ||
| 41 | testlist = rq.recursivescan("XXXXXXXXXXXXXXXXX", recurselevel=1) | ||
| 42 | del rq | ||
| 43 | |||
| 44 | friendliest: str = "" | ||
| 45 | mostfriends: int = 0 | ||
| 46 | for person in testlist: | ||
| 47 | if len(testlist[person]) >= mostfriends: | ||
| 48 | mostfriends = len(testlist[person]) | ||
| 49 | friendliest = person | ||
| 50 | |||
| 51 | print(f"Largest friends list: {mostfriends}, Owned by: {friendliest}") | ||
| 52 | ``` | ||
| 53 | |||
| 54 | ## DOCUMENTATION | ||
| 55 | |||
| 56 | ```python | ||
| 57 | ''' | ||
| 58 | CONSTANTS: | ||
| 59 | Define a constants object: | ||
| 60 | |||
| 61 | from steamrelationships.constants import _Const | ||
| 62 | CONST = _Const() | ||
| 63 | |||
| 64 | CONST.STEAMAPI_MAXREQ = 100000 | ||
| 65 | # Steam's daily API request limit | ||
| 66 | |||
| 67 | CONST.DAY_IN_NANO = (8.64 * (10 ** 13)) | ||
| 68 | # The number of nanoseconds in a day | ||
| 69 | |||
| 70 | CONST.JSON_INDENT = 4 | ||
| 71 | # The indent used when dumping a python object to json | ||
| 72 | ''' | ||
| 73 | |||
| 74 | # Example | ||
| 75 | import time | ||
| 76 | from steamrelationships.constants import _Const | ||
| 77 | CONST = _Const() | ||
| 78 | |||
| 79 | checktime = time.time_ns() | ||
| 80 | oldtime = int(input("Enter a time since the Unix Epoch in nanoseconds: ")) | ||
| 81 | if checktime - oldtime > CONST.DAY_IN_NANO: | ||
| 82 | print("It has been at least 1 day since the entered time") | ||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | ''' | ||
| 87 | STEAMRELATIONSHIPS: | ||
| 88 | Create a SteamRelationships object: | ||
| 89 | import steamrelationships | ||
| 90 | steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") | ||
| 91 | |||
| 92 | basicscan - do a basic scan of someone's steam friends | ||
| 93 | PARAMS: | ||
| 94 | (str) steamid64 - The 64 bit steam id of the user you want to scan | ||
| 95 | |||
| 96 | RETURN VALUES: | ||
| 97 | (dict) EMPTY - There was an error scanning the user's friends list | ||
| 98 | (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 | ||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | recursivescan - Scan a user's friends list, then scan their friends as well | ||
| 103 | |||
| 104 | PARAMS: | ||
| 105 | (str) steamid64 - The starting user to scan | ||
| 106 | (int) recurselevel - The number of recursive scans to complete | ||
| 107 | > Note: 0 is equivalent to a basic scan; 1 scans the specified user, then the user's friends; etc. | ||
| 108 | |||
| 109 | RETURN VALUES: | ||
| 110 | (dict) EMPTY - Some catastrophic error has occured and no scan could be started | ||
| 111 | (dict) { | ||
| 112 | steamid64: | ||
| 113 | [friend1id, friend2id, friend3id, ...], | ||
| 114 | friend1id: | ||
| 115 | [other_friend, other_friend, ...], | ||
| 116 | friend2id: | ||
| 117 | [other_friend, other_friend, ...], | ||
| 118 | friend3id: | ||
| 119 | [other_friend, other_friend, ...], | ||
| 120 | ... | ||
| 121 | } | ||
| 122 | |||
| 123 | - A dict containing the starting steamid, then the friends contained in the original scan with the results of their scan | ||
| 124 | |||
| 125 | NOTE: | ||
| 126 | 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 | ||
| 127 | |||
| 128 | TLDR: recursivescan is exponential and you will reach 100,000 requests very quickly if you recurse greater than 3 | ||
| 129 | ''' | ||
| 130 | |||
| 131 | # Example | ||
| 132 | import steamrelationships | ||
| 133 | |||
| 134 | steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") | ||
| 135 | |||
| 136 | bigscan: dict = steamuser.recursivescan("XXXXXXXXXXXXXXXXX") | ||
| 137 | littlescan: dict = steamuser.basicscan("XXXXXXXXXXXXXXXXX") | ||
| 138 | |||
| 139 | del steamuser | ||
| 140 | |||
| 141 | print(f'Original scanned user: {list(littlescan.keys())[0]}\nOriginal Friends: {littlescan[list(littlescan.keys())[0]]}') | ||
| 142 | |||
| 143 | totalscanned: int = 0 | ||
| 144 | alreadyscanned: list = [] | ||
| 145 | for scanned in bigscan.keys(): | ||
| 146 | totalscanned += 1 | ||
| 147 | alreadyscanned.append(scanned) | ||
| 20 | 148 | ||
| 21 | ```bash | 149 | for friend in bigscan[scanned]: |
| 22 | git clone https://git.dabikers.online/SteamRelationships && cd SteamRelationships | 150 | if friend not in alreadyscanned: |
| 151 | totalscanned += 1 | ||
| 152 | alreadyscanned.append(friend) | ||
| 23 | 153 | ||
| 24 | poetry shell && poetry install | 154 | print(f"Total scanned: {totalscanned}") |
| 25 | ``` | 155 | ``` |
