Skip to main content

Using Python to interact with the AOE2 API

Project description

python-aoe2

How to Use:

Import the library:

>>> from pythonaoe2 import aoe2

Initialize the Client:

>>> client = aoe2.Client()

Or if you are running your own instance of the api:

>>> client = aoe2.Client("https://your.url.here/"+"api_version")

Get Civilizations:

>>> client.get_all_civilizations()

Civilizations are returned as objects:

>>> for civ in client.get_all_civilizations():
>>>     print(civ.name)
Aztecs
...
Vietnamese

Get a Civilization by ID or Name:

>>> client.get_civilization("Aztecs").name
'Aztecs'
>>> client.get_civilization("1").name      
'Aztecs'
>>> 

Get all Units:

>>> for unit in client.get_all_units(): 
>>>     print(unit.name)                  
Archer
...
Elite Woad Raider

Get a Unit by ID or Name:

>>> client.get_unit("1").name 
'Archer'
>>> client.get_unit("Archer").name
'Archer'

Get all structures:

>>> for structure in client.get_all_structures():)  d))
>>>     print(structure.name + "|" + str(structure.id))
Barracks|1
...
Keep|59
>>>

Get Structure by Name or ID:

>>> client.get_structure("59").name
'Keep'
>>> client.get_structure("Keep").name
'Keep'

Get all Technologies:

>>> for tech in client.get_all_technologies(): 
>>>     print(tech.name)
Crossbowman
...
Elite Woad Raider

Get Technology by ID or Name:

>>> client.get_technology("1").name
'Crossbowman'
>>> client.get_technology("Crossbowman").name 
'Crossbowman'

Other Notes:

Some information requires additonal API calls with the provided ID/Name values, and some structures have multiple entries for different ages:

>>> unit = client.get_unit("4")                   
>>> unit.name
'Cavalry Archer'
>>> for structure in client.get_structure(unit.created_in):
>>>     print(structure.name + " | " + structure.age) 
Archery Range | Feudal
Archery Range | Castle
Archery Range | Imperial
>>> tech = client.get_technology("3") 
>>> tech.applies_to
['crossbowman']
>>> tech.develops_in
'archery_range'
>>> unit = client.get_unit(tech.applies_to[0])
>>> unit.name
'Crossbowman'

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

pythonaoe2-0.2.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pythonaoe2-0.2.5-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pythonaoe2-0.2.5.tar.gz.

File metadata

  • Download URL: pythonaoe2-0.2.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for pythonaoe2-0.2.5.tar.gz
Algorithm Hash digest
SHA256 b140d1f98e199b718f1d9ef062df860534f36e434cff4552577bb4d63409b207
MD5 053ff75ae7f2e1673dbe5ab1526e5766
BLAKE2b-256 54d81e6601cc0fea9d8be90503f9501c801cedbe732d9d646cb73e2996ec832c

See more details on using hashes here.

File details

Details for the file pythonaoe2-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: pythonaoe2-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for pythonaoe2-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5897249a53c4f0d9ef609e033f4521aa0a983f0b713a858f20afde953354b820
MD5 ff8ccbd40d2c03d022a083cc945568dd
BLAKE2b-256 518b615579135a2c63ca793ee4ddd488002fbeb4f0381845b52926e009266917

See more details on using hashes here.

Supported by

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