Skip to main content

wrapper around public game statistics for https://ogame.org

Project description

ogame stats

wrapper and logic around public game statistics for https://ogame.org


Some classes and methods to retrieve public data of the online game ogame. This package is NOT intended to interact with an account - which is forbidden anyway.

Might be used to query the data sets, visualize results and generally to do data analysis.

requirements

depends on:

  • python >= 3.6 (uses f-string)
  • xmltodict as a convenience to convert XML data to more basic python types
  • requests to perform http requests and
  • pandas to perform queries on the data

installation

create your virtualenv with your preferred versionin a new directory

virtualenv -p python3.<6,7,8> venv

install the wrapper

pip install ogama_data_api

usage

basic usage

the most basic usage would look like.

#%%
import ogame_stats

#%% supply the two inputs to uniquely identify a universe
universe_id = 162
community = 'en'

#%% instantiate and thereby load the data
universe = ogame_stats.UniverseQuestions(universe_id, community)

than you could take a look at the data sets.

#%% get a list of all the planets
universe.universe
            id  player          name    coords
0            1       1        Arakis     1:1:2
...        ...     ...           ...       ...
[4378 rows x 4 columns]

#%% find some players
universe.players
         id              name status alliance
0         1             Legor      a      NaN
..      ...               ...    ...      ...
[751 rows x 4 columns]

advanced usage

Now, data itself is nice. But lets ask it some questions. This is needs your help since asking the right questions is the key.

e.g. look up the planets of a user.

##%% get the coordinates and names of all the planets of a player
universe.get_planets_of_player('someSpecialName')
[{'coords': '1:45:4', 'name': 'MotherPlanet'},
{'coords': '1:144:2', 'name': 'ColonyC'},
{'coords': '1:145:3', 'name': 'ColonyB'},
{'coords': '1:303:5', 'name': 'ColonyA'}, 
{'coords': '5:119:9', 'name': 'ColonyE'}, 
{'coords': '1:289:9', 'name': 'ColonyD'},
{'coords': '1:389:9', 'name': 'ColonyF'}]

or ask for the status (active, inactive, banned, holiday etc.).

universe.get_player_status('someSpecialName')
'I'

or just dump everything about someSpecialName:

universe.get_player_data('someSpecialName')

get the complete list of players within a specific alliance

universe.get_players_of_alliance('someAlliance')
         id                 name status alliance
291  103910           reabuilder    NaN   500234
292  103930              1 4 Fun      v   500234
312  104181            night owl    NaN   500234
...

get to see the distribution of the planets owned by the alliance members.

universe.get_planets_distribution_by_galaxy('someAlliance')
{'1': 7, '2': 17, '3': 29, '4': 38, '5': 9, '6': 9, '7': 9, '8': 2, '9': 6} 

Update frequencies of data

Don't spam the servers with requests. Since the data sets and classes avoid the usage of XML attributes, it's easy to just pickle your UniverseData for tests, development and everything else. These are the update frequencies I copied over at some point in time (might have changed):

players.xml -> daily
universe.xml -> weekly
highscore.xml -> hourly
alliances.xml -> daily
serverData.xml -> daily
playerData.xml -> weekly
localization.xml -> static
universes.xml -> static

Maybe the easiest way would be to use requests_cache.

import requests_cache
requests_cache.install_cache('demo_cache')

issues/ideas

... are generally welcome. saves us time. Also, the overall design is far from being ideal. Pull requests welcome. Be sure to include the tests.

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

ogame_stats-0.3.6.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

ogame_stats-0.3.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ogame_stats-0.3.6.tar.gz.

File metadata

  • Download URL: ogame_stats-0.3.6.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

File hashes

Hashes for ogame_stats-0.3.6.tar.gz
Algorithm Hash digest
SHA256 ad1d43c43fc9f4c719a0cef8991915f61017efee1be855dd971128e2a43a7efe
MD5 d0c4bf39ff250b4fc270af69cf5a130f
BLAKE2b-256 9579062497ef16d5ec7b3f61a27b3d487ceae8f55edaa8f3b5ed6107e4481c0b

See more details on using hashes here.

File details

Details for the file ogame_stats-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: ogame_stats-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

File hashes

Hashes for ogame_stats-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c85c93f2ba69c0c3f6a555a9628c768a3b9b03098ee5ea5e8e122c02d2e07e40
MD5 d31d74f31eb03e4518ecadb70711738e
BLAKE2b-256 78db2701720999798f01147fb62f913f1d1acddaf0ac272cbc009628921ec649

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