Skip to content

Commit f90eb02

Browse files
authored
Merge pull request #29 from admon84/dev
feat: adding new api methods and prefix parameter
2 parents 9ffbca7 + 2f9f354 commit f90eb02

File tree

4 files changed

+431
-162
lines changed

4 files changed

+431
-162
lines changed

README.md

+20-19
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,65 @@ This is an unofficial client for the [Screeps](https://screeps.com/) Unoffical A
44

55
Since the API is unofficial it could in theory change at any time. In practice though breaking changes are rare.
66

7+
## Setup
78

8-
## Setup:
9-
10-
Simply install the library using `pip`.
11-
9+
Simply install the Python `screepsapi` library using `pip`.
1210

1311
## Usage
1412

1513
### Authentication
1614

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.
1816

1917
```python
2018
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)
2421
```
2522

23+
An optional `prefix` parameter can be included with values such as `"/ptr"` for the public test realm or `"/season"` for seasonal server.
2624

2725
It is also possible to access private servers with the `host` and `secure` parameters.
2826

2927
```python
3028
import screepsapi
3129
USER = "MyUsername"
3230
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)
3433
```
3534

3635
Note that by default private servers do not use SSL and all traffic is unencrypted.
3736

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+
3841
### API
3942

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.
4144

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)
4346

4447
#### Console Example
4548

4649
```python
4750
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)
5153

5254
# Run "Game.time" on shard1 via the console
53-
api.console('Game.time', shard='shard1')
55+
api.console("Game.time", shard="shard1")
5456
```
5557

5658
#### User Information Example
5759

5860
```python
5961
import screepsapi
60-
USER = "MyUsername"
61-
PASSWORD = "TimeTravelingSecretAgentForHire"
62-
api = screepsapi.API(USER, PASSWORD, host="server1.screepspl.us:443", secure=True)
62+
TOKEN = "3bdd1da7-3002-4aaa-be91-330562f54093"
63+
api = screepsapi.API(token=TOKEN)
6364

64-
# Find the GCL for `tedivm`
65+
# Find the GCL for "tedivm"
6566
user = api.user_find("tedivm")
6667
print user["user"]["gcl"]
6768
```

0 commit comments

Comments
 (0)