Bungie.Net API Documentation

repository·master·Indexed 23 days ago

https://github.com/bungie-net/api

Programmatic access to Destiny 2 game data, including player profiles, item definitions, activity details, and seasonal content. Features component-based requests via Destiny2.GetProfile, GetCharacter, and GetItem, as well as the InsertSocketPlugFree API for reversible socket actions. Provides OpenAPI specifications with custom extensions for manifest mapping and component dependencies. Also includes access to the Destiny 1 API.

Tokens
2.1K
Snippets
1
Records
17
Agent score
30%

What's inside Bungie.Net API

  1. Handle String Variable placeholders in localized strings

    master

    Destiny definition localized strings often contain placeholders formatted as {var:1234567890}.

    To resolve these, D2 Profile API clients can request the StringVariables component. This component provides per-character integer values mapped by hash. You can then replace the {var:(hash)} placeholders in your UI with the corresponding integer values provided by the API.

  2. Handle OAuth scopes and Component access

    master

    When calling GetProfile, GetCharacter, or GetItem, your access to specific data subsets (Components) depends on your OAuth scopes. If you lack the required scope, the API will not deny the entire request, but it will omit the specific requested components.

    Required Scopes:

    • ReadDestinyVendorsAndAdvisors: Required for characterActivities, characterProgressions, kiosks, and characterKiosks.
    • ReadDestinyInventoryAndVault: Required for profileCurrencies, profileInventory, characterInventories, and vendorReceipts.

    Important: Always design your application to handle cases where an expected Component is missing from the response, whether due to insufficient OAuth scopes or the user's privacy settings.

  3. Understand Milestones in Destiny 2

    master

    Milestones have replaced 'Advisors' to reflect the activities a player can perform in-game. They are associated with Definition data, which reduces the payload size in live requests.

    There are two types of Milestones:

    1. Player-specific Milestones: Reflect an individual player's state.
    2. Public Milestones: Views of what can be done in the game currently, agnostic of an individual player's state. Use Destiny2.GetPublicMilestones to access these.
  4. Use component-based requests for Destiny 2 data

    master

    Destiny 2 data is retrieved using fundamental building blocks rather than specialized endpoints. The primary methods are:

    • Destiny2.GetProfile (Recommended for most use cases)
    • Destiny2.GetCharacter (Use when the specific character is known in your UI)
    • Destiny2.GetItem (Use when the specific item is known in your UI)

    To control bandwidth and payload size, use the ?components= query string parameter to request only the specific data components you need. For example, passing the CharacterInventories component to GetProfile will return the full inventory for all characters (subject to user privacy permissions).

  5. Configure the User-Agent header for API requests

    master

    While the API does not strictly require a User-Agent header, it is considered best practice to include one. This helps Bungie identify your application and provide metrics or contact you if necessary.

    Use the following suggested format: AppName/Version AppId/appIdNum (+webUrl;contactEmail)

    Example: User-Agent: Really Cool App/1.0 AppId/##### (+www.example.com;contact@example.com)

    User-Agent: Really Cool App/1.0 AppId/#####  (+www.example.com;contact@example.com)
  6. Generate API clients using OpenAPI specs

    master

    You can generate your own client libraries for the Bungie.Net API using the provided OpenAPI specifications. Note that there may be bugs or missing data in the generated documentation, so verify your client implementation against the actual API behavior.

  7. Handle stale cached responses from GetProfile

    master

    When using the Destiny2.GetProfile API, use the following fields in the DestinyProfileResponse to determine if your cached data is stale:

    • responseMintedTimestamp
    • secondaryComponentsMintedTimestamp
  8. Handle HTML responses during environment downtime

    master
    If the Bungie.Net environment is down, the API may return static HTML error pages instead of JSON. Your application should detect if the response body is HTML and handle it with appropriate error messaging rather than attempting to parse it as JSON.
  9. Avoid WebAuthRequired errors by using correct URLs

    master

    If you receive a WebAuthRequired error despite providing both X-API-Key and Authorization headers, ensure you are following these URL requirements:

    1. Use https://www.bungie.net instead of https://bungie.net. Using the latter can trigger a redirect that strips your authorization headers.
    2. Ensure your URLs terminate with a trailing slash (/).
  10. Retrieve Crucible player scores from PGCR

    master

    The DestinyPostGameCarnageReportExtendedData object now includes a scoreboardValues field. This field provides detailed Crucible player statistics, including:

    • Player scores
    • Reward scores
    • Multipliers

    Note that there may be some overlap between scoreboardValues and other existing stat values within Post-Game Carnage Reports (PGCRs).