Skip to content

feat: adding new api methods and prefix parameter #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,65 @@ This is an unofficial client for the [Screeps](https://screeps.com/) Unoffical A

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

## Setup

## Setup:

Simply install the library using `pip`.

Simply install the Python `screepsapi` library using `pip`.

## Usage

### Authentication

To authenticate to the primary servers just supply a username and password.
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.

```python
import screepsapi
USER = "MyUsername"
PASSWORD = "TimeTravelingSecretAgentForHire"
api = screepsapi.API(USER, PASSWORD)
TOKEN = "3bdd1da7-3002-4aaa-be91-330562f54093"
api = screepsapi.API(token=TOKEN)
```

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

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

```python
import screepsapi
USER = "MyUsername"
PASSWORD = "TimeTravelingSecretAgentForHire"
api = screepsapi.API(USER, PASSWORD, host="server1.screepspl.us:443", secure=True)
HOST = "server1.screepspl.us:443"
api = screepsapi.API(USER, PASSWORD, host=HOST, secure=True)
```

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

### Credentials

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.

### API

The API itself is a simple REST-based API. Each method in the api library corresponds to a different endpoint for the API.
The API class is a simple REST-based API. Each method corresponds to a different Screeps API endpoint.

The best way to discover functionality is to read through the library itself.
The best way to discover functionality is to read through the [screepsapi library](screepsapi/screepsapi.py) or [Endpoints.md](docs/Endpoints.md)

#### Console Example

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

# Run "Game.time" on shard1 via the console
api.console('Game.time', shard='shard1')
api.console("Game.time", shard="shard1")
```

#### User Information Example

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

# Find the GCL for `tedivm`
# Find the GCL for "tedivm"
user = api.user_find("tedivm")
print user["user"]["gcl"]
```
Expand Down
Loading