Supremacy 1914 API Wrapper
This unofficial API wrapper is an implementation of the Supremacy 1914 API. This wrapper support API data as far as known and is intended to be easy to use. You'll only need to supply the server URL and the game_id before you'll be able to get data.
Install
$ pip install supremacy1914-wrapper
Demo
It's advised to store the server url for the game you want to request. If you don't have the server url you can make a Supremacy instance without the url parameter, wrap it in a try except to get the server url.
from supremacy1914_wrapper import Supremacy, ServerChangeError
# Create a Supremacy instance using game id
supremacy = Supremacy("2502620")
# Send a request and except server change error
try:
result = supremacy.players()
except ServerChangeError as exception:
# update the url in the Supremacy instance
supremacy.url = str(exception)
result = supremacy.players()
When you have to server url from the game you can pass it into the Supremacy constructor. Make sure to use a try except because the server changes over time.
from supremacy1914_wrapper import Supremacy, ServerChangeError
# Create a Supremacy instance using game id and server url
supremacy = Supremacy("2502620", "http://xgs1.c.bytro.com")
# Send a request and except server change error
try:
result = supremacy.players()
except ServerChangeError as exception:
# update the url in the Supremacy instance
supremacy.url = str(exception)
result = supremacy.players()
Documentation
Other information about functions and exceptions can be found on the wiki.
Tests
Testing is done with PyTest, to run the tests use the command pytest. The following environment variables are required: TEST_GAME_ID and TEST_GAME_URL, save those in the .env file for convince
Development
I'll try to improve the wrapper as far as I need. If you'd like to see a new feature you can open an issue or make pull request.
Release files for supremacy1914-wrapper 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| supremacy1914_wrapper-0.1.4.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| supremacy1914_wrapper-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / supremacy1914_wrapper-0.1.4.tar.gz
| Download URL | supremacy1914_wrapper-0.1.4.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7f1cf2f5ab24ff741ef7c2c16f9e2355a1612680feb0627af6e94e09ee087f8
|
|
BLAKE2b-256 checksum How to use checksums |
4e2307586ce14376087acc6c8d166bc77bda845b04bdb202484b02f5b3c7a9b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3
|
Release files / supremacy1914_wrapper-0.1.4-py3-none-any.whl
| Download URL | supremacy1914_wrapper-0.1.4-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b316566492db07ce68fd3593eafd82fa0c3f868ea1ae36158f6c374cdac8680a
|
|
BLAKE2b-256 checksum How to use checksums |
94800445dd0e16b42ea3a0e1d7b13e11f82101e1af1f92c9ac0c453c764e48e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3
|