Exposing attributes and other entity information
Last updated
Last updated
With Kanka 2.4, a partial JavaScript dump was added for entity attributes and a handful of other information. As of 2.7, this object now includes most of the entity’s information relevant to a character sheet, with the notable exception of abilities. You can access them via the entityData
object, which contains the following fields (further detailed on the ):
Note that the attribute names used by entityData
don’t match their Blade counterparts when it comes to capitalization, which can make interactions between the two languages difficult. On the other hand, it makes it possible to interact with attributes whose name is invalid in Blade, for example those that contain special characters.
Kanka 2.7 introduced tools to access the API via axios
methods that interact with an entity’s attributes and abilities. This allows us to generate a more thorough attribute dump (including for example attribute types and pinned status) with names that match those used in Blade, as well as a thorough dump of ability information.
However, because axios is only initialized after the page is fully loaded, unlike our character sheet scripts, window.onload
is necessary to defer execution until axios is ready. Any processing that relies on the attribute/ability dumps must therefore also be deferred.
Each attribute value can then be accessed with a simple attributes.slug.value
, where slug
matches the attribute’s corresponding Blade variable:
Several other details are available via attributes.slug
, beyond what is accessible in Blade; for example:
We also get a ton of information about abilities, grouped by their parent field like in the Abilities page of the entity; for example:
Most notably, the apis
object provides the necessary URLs to for attributes.