Client

class ourdestiny.d2client(api_key_in, client_id_in, client_secret_in)

The main object that represents your application - automatically authenticates and downloads databases when needed.

Parameters:
  • api_key_in – The API key gotten from Bungie’s website
  • client_id_in – The client ID gotten from Bungie’s website
  • client_secret_in – The client secret gotten from Bungie’s website
Variables:
  • api_key (string) – The same API key gotten from Bungie’s website, should be the same as during initialisation
  • client_id (string) – The same client ID gotten from Bungie’s website, should be the same as during initialisation
  • client_secret (string) – The same client secret gotten from Bungie’s website, should be the same as during initialisation
  • auth_code (string) – The auth code needed to get the access token - if this is already stored, this attribute will be an empty string, as there is no need to go through the full OAuth2 process
  • access_token (string) – The access token needed to authenticate with the API
  • refresh_token (string) – The refresh token needed in case the access token expires
  • root_endpoint (string) – The root endpoint needed to communicate with the API
  • request_header (dict) – Once authenticated, will allow for any request to be correctly authenticated with the API
  • bungie_membership_id (string) – When retrieved, contains the currently authenticated user’s Bungie membership ID, also sometimes called bungienet ID
  • destiny_membership_id – When obtained, contains the currently authenticated user’s Destiny membership ID, needed for most operations to do with the game
  • asset_database (sqlite3.cursor) – Contains a sqlite3 Cursor object linked to the asset database file - see https://docs.python.org/3.8/library/sqlite3.html#sqlite3.Cursor
  • gear_database (sqlite3.cursor) – Contains a sqlite3 Cursor object linked to the gear database file - see https://docs.python.org/3.8/library/sqlite3.html#sqlite3.Cursor
  • world_database (sqlite3.cursor) – Contains a sqlite3 Cursor object linked to the world database file (the one you’ll be using most of the time) - see https://docs.python.org/3.8/library/sqlite3.html#sqlite3.Cursor
  • clan_banner_database (sqlite3.cursor) – Contains a sqlite3 Cursor object linked to the clan banner database file - see https://docs.python.org/3.8/library/sqlite3.html#sqlite3.Cursor
check_for_destiny_db_update()

Checks through all downloaded databases and checks if there are any updates to any of them - there should be no need to call this, as it should be called automatically during the initialisation process

connect_all_destiny_db()

Checks if the path to the database files exists, and places the cursor objects for those sqlite databases into the specified class variables

download_all_destiny_db()

Downloads all database files, unzips and adds them to the relevant dbinfo.json - normally used automatically in the case of a blank slate

download_one_destiny_db(dbtype, url)

Downloads a single database file, unzips it and adds or updates the relevant dbinfo.json entry

Parameters:
  • dbtype (string) – The type of database - this can be mobileAssetContent, mobileGearAssetDataBase, mobileWorldContent, or mobileClanBannerDatabase
  • url (string) – The URL of the database file to download
get_bungienetuser_with_membership_id(membership_id, platform)

Gets a user’s bungienetuser object using their membership ID and the platform they are on.

Parameters:
  • membership_id (string) – The membership ID for the desired user
  • platform (string) – The platform the desired user is on
Returns:

The bungienetuser object for the desired user

Return type:

ourdestiny.bungienetuser

get_bungienetusers_with_search_name(search_string)

Gets a list of bungienetusers based on a search string inputted.

Parameters:search_string (string) – String to search for in usernames
Returns:A list of bunginetuser objects based on the search string
Return type:List[ourdestiny.bungienetuser]
get_component_json(platform, destiny_membership_id, list_of_enums)

Gets game-related profile information of the corresponding user of the Destiny membership ID - see https://bungie-net.github.io/multi/operation_get_Destiny2-GetProfile.html

Parameters:
Returns:

Profile data based on enums given - see https://bungie-net.github.io/multi/schema_Destiny-Responses-DestinyProfileResponse.html

Return type:

dict

get_destiny_manifest(testing=False)

Gets the Destiny manifest, which contains links to all sqlite and json databases

Parameters:testing (boolean, optional) – Variable used in the authentication process to check that an already stored access token is still valid, defaults to False
Returns:JSON of manifest
Return type:dict
get_from_db(hashnum, table, database='mobileWorldContent')

Gets a JSON item from the local sqlite database, using a hash given from the API.

Parameters:
  • hashnum (string, integer) – The hash number given by the API
  • table (string) – The table in which to lookup the hash (only the unique part of the table name is needed, for example “lore” instead of “DestinyLoreDefinition”)
  • database (string, optional) – The database in which to lookup the hash, defaults to world database
Returns:

A JSON of the relevant data

Return type:

dict

get_membership_type_enum(platform)

Takes a more generic string of a plaform name and returns the relevant membership type enumerator

Parameters:platform (string, integer) – The name or enum of the platform the current user is on
Returns:The enumerator form of whatever platform name was passed in
Return type:string
get_my_bungie_net_user()

Gets the bungienet object of the currently authenticated user - see https://bungie-net.github.io/multi/operation_get_User-GetBungieNetUserById.html

Returns:A bungienetuser object of the current user’s bungienet data - see https://bungie-net.github.io/multi/schema_User-GeneralUser.html
Return type:ourdestiny.bungienetuser
get_my_profile(platform)

Gets a profile object for the currently authenticated user - see https://bungie-net.github.io/multi/operation_get_Destiny2-GetProfile.html

Parameters:platform (string, integer) – The name or enum of the platform the current user is on
Returns:A d2profile object for the currently authenticated user
Return type:ourdestiny.d2profile
get_profile(platform, destiny_membership_id)

Gets a profile object based on the platform and membership ID passed in.

Parameters:
  • platform (string, integer) – The name or enum of the platform the user is on
  • destiny_membership_id (string) – The Destiny membership ID of the user that owns the desired profile
Returns:

The d2profile object of the desired profile

Return type:

ourdestiny.d2profile

get_profile_with_search_string(search_string, platform)

Gets a d2profile object based on a search string inputted.

Parameters:
  • search_string (string) – String to search for in usernames
  • platform (string) – The platform the desired profile is on
Returns:

The d2profile of the desired user

Return type:

ourdestiny.d2profile

search_destiny_player(displayname, platform)

Searches and returns the Destiny 2 data of a given display name - see https://bungie-net.github.io/multi/operation_get_Destiny2-SearchDestinyPlayer.html

Parameters:
  • displayname (string) – The full gamertag or PSN id of the player. Spaces and case are ignored.
  • platform (string, integer) – The name or enum of the platform the current user is on
Returns:

A JSON of Destiny user info - see https://bungie-net.github.io/multi/schema_User-UserInfoCard.html

Return type:

dict

test_access_token()

Called during the initialisation process, tests if the currently stored access token exists and if it is valid.

unzip_db_zip(zipfile_path, dbtype)

Unzips a zip file downloaded from bungie.net containing a database file, and adds or updates the corresponding entry in the dbinfo.json file

Parameters:
  • zipfile_path (string) – The path to the zip file containing the database file
  • dbtype (string) – The type of database - this can be mobileAssetContent, mobileGearAssetDataBase, mobileWorldContent, or mobileClanBannerDatabase
class ourdestiny.ComponentType

An enumeration. See https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html