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

Uploaded Source

Built Distribution

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

Uploaded Python 3

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