Skip to main content

Using Python to interact with the AOE2 API

Project description


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(""+"api_version")

Get Civilizations:

>>> client.get_all_civilizations()

Civilizations are returned as objects:

>>> for civ in client.get_all_civilizations():
>>>     print(

Get a Civilization by ID or Name:

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

Get all Units:

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

Get a Unit by ID or Name:

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

Get all structures:

>>> for structure in client.get_all_structures():)  d))
>>>     print( + "|" + str(

Get Structure by Name or ID:

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

Get all Technologies:

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

Get Technology by ID or Name:

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

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")                   
'Cavalry Archer'
>>> for structure in client.get_structure(unit.created_in):
>>>     print( + " | " + structure.age) 
Archery Range | Feudal
Archery Range | Castle
Archery Range | Imperial
>>> tech = client.get_technology("3") 
>>> tech.applies_to
>>> tech.develops_in
>>> unit = client.get_unit(tech.applies_to[0])

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

Uploaded Source

Built Distribution

pythonaoe2-0.2.5-py3-none-any.whl (4.1 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