Skip to content

Commit

Permalink
Add support for Destiny Entity (#21)
Browse files Browse the repository at this point in the history
* add support for entity definition manifest endpoint

* update get_destiny_entity_definition description

* added destiny entity def to readme
  • Loading branch information
aescolastico authored Feb 28, 2022
1 parent 42ed4f4 commit fc8c589
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ Get the current version of the manifest. This api call shouldn't be needed much,

---

> get_destiny_entity_definition(entity_type, hash_identifier)
This function is a coroutine.

Returns the static definition of an entity of the given Type and hash identifier

**Parameters**
- `entity_type` - The type of entity - ex. 'DestinyInventoryItemDefinition'
- `hash_identifier` - The hash identifier for the specific Entity you want returned.

**Response**:
See [Destiny2.GetDestinyEntityDefinition](https://bungie-net.github.io/multi/schema_Destiny-Definitions-DestinyDefinition.html#schema_Destiny-Definitions-DestinyDefinition)

---

> search_destiny_entities(entity_type, search_term, page=0)
This function is a coroutine.
Expand Down
28 changes: 27 additions & 1 deletion pydest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,33 @@ async def get_destiny_manifest(self):
url = DESTINY2_URL + 'Manifest'
return await self._get_request(url)


async def get_destiny_entity_definition(self, entity_type, hash_identifier):
"""Returns the static definition of an entity of the given Type and hash identifier.
Examine the API Documentation for the Type Names of entities that have their own definitions.
Note that the return type will always *inherit from* DestinyDefinition, but the specific type
returned will be the requested entity type if it can be found. Please don't use this as a chatty
alternative to the Manifest database if you require large sets of data, but for simple and one-off
accesses this should be handy.
Args:
entity_type:
The type of entity for whom you would like results. These correspond to the entity's
definition contract name. For instance, if you are looking for items, this property
should be 'DestinyInventoryItemDefinition'. PREVIEW: This endpoint is still in beta,
and may experience rough edges. The schema is tentatively in final form, but there may
be bugs that prevent desirable operation.
hash_identifier:
The hash identifier for the specific Entity you want returned.
Returns:
json (dict)
"""
url = DESTINY2_URL + 'Manifest/{}/{}/'
url = url.format(entity_type, hash_identifier)
return await self._get_request(url)


async def search_destiny_entities(self, entity_type, search_term, page=0):
"""Gets a page list of Destiny items
Expand Down Expand Up @@ -378,4 +404,4 @@ async def get_activity_history(self, membership_type, membership_id, character_i
"""
# /{membershipType}/Account/{destinyMembershipId}/Character/{characterId}/Stats/Activities/
url = DESTINY2_URL + '{}/Account/{}/Character/{}/Stats/Activities/?mode={}&count={}&page={}'.format(membership_type, membership_id, character_id, mode, count, page)
return await self._get_request(url)
return await self._get_request(url)

0 comments on commit fc8c589

Please sign in to comment.