You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+20-19
Original file line number
Diff line number
Diff line change
@@ -4,64 +4,65 @@ This is an unofficial client for the [Screeps](https://screeps.com/) Unoffical A
4
4
5
5
Since the API is unofficial it could in theory change at any time. In practice though breaking changes are rare.
6
6
7
+
## Setup
7
8
8
-
## Setup:
9
-
10
-
Simply install the library using `pip`.
11
-
9
+
Simply install the Python `screepsapi` library using `pip`.
12
10
13
11
## Usage
14
12
15
13
### Authentication
16
14
17
-
To authenticate to the primary servers just supply a username and password.
15
+
The recommended way to authenticate to the official servers is providing an [Authorization Token](https://docs.screeps.com/auth-tokens.html) in the `token` parameter.
18
16
19
17
```python
20
18
import screepsapi
21
-
USER="MyUsername"
22
-
PASSWORD="TimeTravelingSecretAgentForHire"
23
-
api = screepsapi.API(USER, PASSWORD)
19
+
TOKEN="3bdd1da7-3002-4aaa-be91-330562f54093"
20
+
api = screepsapi.API(token=TOKEN)
24
21
```
25
22
23
+
An optional `prefix` parameter can be included with values such as `"/ptr"` for the public test realm or `"/season"` for seasonal server.
26
24
27
25
It is also possible to access private servers with the `host` and `secure` parameters.
28
26
29
27
```python
30
28
import screepsapi
31
29
USER="MyUsername"
32
30
PASSWORD="TimeTravelingSecretAgentForHire"
33
-
api = screepsapi.API(USER, PASSWORD, host="server1.screepspl.us:443", secure=True)
31
+
HOST="server1.screepspl.us:443"
32
+
api = screepsapi.API(USER, PASSWORD, host=HOST, secure=True)
34
33
```
35
34
36
35
Note that by default private servers do not use SSL and all traffic is unencrypted.
37
36
37
+
### Credentials
38
+
39
+
Developers are encouraged to align with [SS3: Unified Credentials File v1.0](https://github.com/screepers/screepers-standards/blob/master/SS3-Unified_Credentials_File.md) to standardize Screeps credentials storage with other third party tools.
40
+
38
41
### API
39
42
40
-
The API itself is a simple REST-based API. Each method in the api library corresponds to a different endpoint for the API.
43
+
The API class is a simple REST-based API. Each method corresponds to a different Screeps API endpoint.
41
44
42
-
The best way to discover functionality is to read through the library itself.
45
+
The best way to discover functionality is to read through the [screepsapi library](screepsapi/screepsapi.py) or [Endpoints.md](docs/Endpoints.md)
43
46
44
47
#### Console Example
45
48
46
49
```python
47
50
import screepsapi
48
-
USER="MyUsername"
49
-
PASSWORD="TimeTravelingSecretAgentForHire"
50
-
api = screepsapi.API(USER, PASSWORD, host="server1.screepspl.us:443", secure=True)
51
+
TOKEN="3bdd1da7-3002-4aaa-be91-330562f54093"
52
+
api = screepsapi.API(token=TOKEN)
51
53
52
54
# Run "Game.time" on shard1 via the console
53
-
api.console('Game.time', shard='shard1')
55
+
api.console("Game.time", shard="shard1")
54
56
```
55
57
56
58
#### User Information Example
57
59
58
60
```python
59
61
import screepsapi
60
-
USER="MyUsername"
61
-
PASSWORD="TimeTravelingSecretAgentForHire"
62
-
api = screepsapi.API(USER, PASSWORD, host="server1.screepspl.us:443", secure=True)
0 commit comments