Skip to main content

Supremacy1914 API wrapper in Python

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

supremacy1914_wrapper-0.1.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

supremacy1914_wrapper-0.1.4-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file supremacy1914_wrapper-0.1.4.tar.gz.

File metadata

  • Download URL: supremacy1914_wrapper-0.1.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for supremacy1914_wrapper-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f7f1cf2f5ab24ff741ef7c2c16f9e2355a1612680feb0627af6e94e09ee087f8
MD5 d908b2549e62e54cd5d1a14a0a0cf5a2
BLAKE2b-256 4e2307586ce14376087acc6c8d166bc77bda845b04bdb202484b02f5b3c7a9b6

See more details on using hashes here.

File details

Details for the file supremacy1914_wrapper-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: supremacy1914_wrapper-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for supremacy1914_wrapper-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b316566492db07ce68fd3593eafd82fa0c3f868ea1ae36158f6c374cdac8680a
MD5 faa32b447a828d5182d2f0992b6bc3fa
BLAKE2b-256 94800445dd0e16b42ea3a0e1d7b13e11f82101e1af1f92c9ac0c453c764e48e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page