summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md148
1 files changed, 139 insertions, 9 deletions
diff --git a/README.md b/README.md
index 9cb5619..615fb9a 100644
--- a/README.md
+++ b/README.md
@@ -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
111. A [Steam Developer API key](https://steamcommunity.com/dev/apikey) 111. Python 3.10 or greater
122. [Poetry](https://python-poetry.org/) 122. [Requests](https://docs.python-requests.org/en/latest/index.html) 2.31.0 or greater
133. A [Steam Developer API key](https://steamcommunity.com/dev/apikey)
14
15If using [Poetry](https://python-poetry.org/), all Python dependencies are fetched automatically
13 16
14## INSTALLATION 17## INSTALLATION
15 18
161. Clone the repo 19### Pip version
172. [Install poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) (if poetry isn't already installed) 20
183. Open a `poetry shell` 211. Run `pip install steamrelationships`
194. Run `poetry install` 22
23### Poetry Version
24
251. In a poetry shell, run `poetry add steamrelationships`
262. Import the package `import steamrelationships`
273. Create an object (example: `steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")`)
284. Do a scan (example: `results = steamuser.basic_scan("XXXXXXXXXXXXXXXXX")`)
29
30Example:
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
37import steamrelationships
38
39if __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'''
58CONSTANTS:
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
75import time
76from steamrelationships.constants import _Const
77CONST = _Const()
78
79checktime = time.time_ns()
80oldtime = int(input("Enter a time since the Unix Epoch in nanoseconds: "))
81if checktime - oldtime > CONST.DAY_IN_NANO:
82 print("It has been at least 1 day since the entered time")
83
84
85
86'''
87STEAMRELATIONSHIPS:
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
132import steamrelationships
133
134steamuser: object = steamrelationships.SteamRelationships(webapikey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
135
136bigscan: dict = steamuser.recursivescan("XXXXXXXXXXXXXXXXX")
137littlescan: dict = steamuser.basicscan("XXXXXXXXXXXXXXXXX")
138
139del steamuser
140
141print(f'Original scanned user: {list(littlescan.keys())[0]}\nOriginal Friends: {littlescan[list(littlescan.keys())[0]]}')
142
143totalscanned: int = 0
144alreadyscanned: list = []
145for scanned in bigscan.keys():
146 totalscanned += 1
147 alreadyscanned.append(scanned)
20 148
21```bash 149 for friend in bigscan[scanned]:
22git clone https://git.dabikers.online/SteamRelationships && cd SteamRelationships 150 if friend not in alreadyscanned:
151 totalscanned += 1
152 alreadyscanned.append(friend)
23 153
24poetry shell && poetry install 154print(f"Total scanned: {totalscanned}")
25``` 155```