-
Notifications
You must be signed in to change notification settings - Fork 8
Home
Auraxium is a Python wrapper for the Daybreak Game Company Census API. While its core components have been designed to work with any title using the Census API syntax, it is mainly being developed and tested with PlanetSide 2 in mind.
Auraxium was born out of frustrating attempts to write a Discord bot for my PlanetSide 2 outfit that would automate certain tasks like logging member activity or retrieving outfit-leaderboard information from outside the game.
It quickly became apparent that hard-coding the URLs required was unfeasible, and attempts to generate them quickly turned into unwieldy syntax abominations that were even more inconvenient than finding the typos in the URLs through trial-and-error.
The result of this quest is Auraxium, which attempts to solve this by abstracting the URL generation through objects and hiding as much of the dirty work from the user as possible.
Before you read on, you might want to take a look at a bit of example code to see if you like the syntax. Here is a carefully curated selection of code snippets:
These examples will work analogously for all Census API supported games.
Example 1: Looking up the Terran Republic in PlanetSide 2:
import auraxium
print(Query('faction', namespace='ps2', faction_id='3').get())
Example 2: Finding a list of all "Pulsar" weapons in PlanetSide 2:
import auraxium
# Note: Weapons don't have names, only items do. Thus, we are looking for items
query = auraxium.Query('item', namespace='ps2', name__en='*Pulsar').limit(100)
for item in query.get():
print(item['name']['en'])
Example 3: Looking up a weapon by name and joining the weapon information:
import auraxium
# Create the main query for the item
query = auraxium.Query('item', namespace='ps2', name__en='^Orion').lang('en')
# Attach the intermediate "item_to_weapon" collection
join = query.join('item_to_weapon', on='item_id', to='weapon_id')
# Resolve the weapon collection using the id retrieved earlier
join.join('weapon', on='weapon_id', to='weapon_id')
# Print the response
print(query.get())
This functionality is currently only supported for the ps2
namespace.
Example 4: Looking up a weapon by name. This example is functionally identical to #3, just far cleaner and more intuitive:
from auraxium.object_models import ps2
# Note that the Weapon object created can be kept around once populated
print(ps2.Weapon.get_by_name('^Orion', locale='en'))
Example 5: Looking up a character by name and printing the English locale name of the server that character resides on:
from auraxium.object_models import ps2
my_char = ps2.Character.get_by_name('Auroram')
print(my_char.world.name.en)
This last example is a good showcase of the power of the object-oriented interface provided by the object_models
submodule. Character.world
is a property that hides the request to the characters_world
collection.
If you are unfamiliar with the Census API or would like a refresher, check out the Census API Primer.
Seasoned API users - or people who already decided that they want to use the object model system - can jump straight into the fray with your system of choice.
This is not a final decision, they're perfectly compatible. The object model system is more intuitive and better suited for user interaction, the query object system is more flexible and has less overhead.
This Wiki only contains general Census API topics, development notes and other version-independent documentation.
Visit Read the Docs for usage examples and the full API reference.