-
Notifications
You must be signed in to change notification settings - Fork 1
KankaClient class
This class is the core of pykanka. It should normally be the only class initialized directly by the user.
KankaClient(token: str, campaign: Union[str, int], cache_duration: int)token: A Kanka API token. This is needed to access user campaigns and can be generated here: https://kanka.io/en/settings/api.
campaign: Either a campaign ID as an integer, or a campaign name as a string.
cache_duration Duration in seconds for requests to be cached. Set to 0 to disable caching.
KankaClient.search(name: int, results: int = 1)name: The term to be searched.
results: Number of results to return. Since the 'search' endpoint doesn't return all entity data, a separate API call is needed for each result, so a low number is desirable.
returns: A list of Entity object matching the search term.
KankaClient.get_entity(entity: int = None)entity_id: Entity ID as an integer.
returns: An Entity object. If an ID is provided, it requests it from kanka.io, otherwise an empty Entity object is created.
KankaClient.get_character(character_id: int = None)character_id: Character ID as an integer, can be found at the end of Character URLSs on kanka.io.
returns: A character object. If an ID is provided, it requests it from kanka.io, otherwise an empty Character object is created.
KankaCLient.all_characters()returns: A tuple consisting of a generator object that yields Character objects and the total number of characters as an int.