XBox live achievements API
Categories:
Integrating with the Xbox Live Achievements API

Explore the process of accessing and displaying Xbox Live achievement data for your applications, including authentication and API interaction.
The Xbox Live Achievements API allows developers to retrieve achievement data for Xbox Live users. This can be incredibly useful for companion apps, fan sites, or any application that wants to display a user's gaming accomplishments. While Microsoft provides official SDKs for Xbox development, directly interacting with the REST API offers flexibility for various platforms and custom integrations. This article will guide you through the fundamental steps, from understanding the API structure to making authenticated requests.
Understanding the Xbox Live API Ecosystem
Before diving into achievements, it's crucial to grasp the broader Xbox Live API landscape. Accessing user data, including achievements, requires proper authentication and authorization. Microsoft uses OAuth 2.0 for user authentication, typically involving a user signing in through a Microsoft account to grant your application permission to access their data. The Xbox Live API is part of a larger set of Microsoft Graph APIs, but for game-specific data like achievements, you'll often interact with dedicated Xbox Live endpoints.
sequenceDiagram participant User participant YourApp as "Your Application" participant MicrosoftAuth as "Microsoft Auth Server" participant XboxAPI as "Xbox Live API" User->>YourApp: Initiates Login/Auth YourApp->>MicrosoftAuth: Request Authorization Code (OAuth 2.0) MicrosoftAuth-->>User: Redirect to Login Page User->>MicrosoftAuth: Enters Credentials & Grants Consent MicrosoftAuth-->>YourApp: Redirect with Authorization Code YourApp->>MicrosoftAuth: Exchange Code for Access Token MicrosoftAuth-->>YourApp: Returns Access Token & Refresh Token YourApp->>XboxAPI: Request Achievements (with Access Token) XboxAPI-->>YourApp: Returns Achievement Data YourApp->>User: Displays Achievements
Typical OAuth 2.0 flow for accessing Xbox Live API data.
Authentication and Authorization
The first and most critical step is authenticating your application and obtaining an access token. This typically involves registering your application with Microsoft, obtaining a Client ID and Client Secret, and then implementing the OAuth 2.0 authorization code flow. Once you have an access token, you can include it in the Authorization
header of your API requests. Remember that access tokens have a limited lifespan, so you'll also need to implement a refresh token mechanism to maintain continuous access without requiring the user to re-authenticate frequently.
GET https://achievements.xboxlive.com/users/xuid({xuid})/achievements
Authorization: Bearer {access_token}
X-XBL-Contract-Version: 1
Accept: application/json
Example HTTP GET request to the Xbox Live Achievements API.
Retrieving Achievement Data
Once authenticated, you can make requests to the Xbox Live Achievements API. The primary endpoint for achievements usually involves the user's Xbox User ID (XUID). You'll need to know the XUID of the user whose achievements you want to retrieve. The API response will typically be in JSON format, containing details about unlocked achievements, their descriptions, images, and unlock timestamps. You might also need to specify a title ID (game ID) to filter achievements for a specific game.
{
"achievements": [
{
"id": "123456789",
"name": "First Blood",
"titleId": 1234567890,
"titleName": "Awesome Game",
"isUnlocked": true,
"unlockedDate": "2023-10-26T10:30:00Z",
"description": "Unlock your first achievement.",
"mediaAssets": [
{
"url": "https://assets.xboxlive.com/achievement/123456789.png",
"type": "Icon"
}
]
},
{
"id": "987654321",
"name": "Master Explorer",
"titleId": 1234567890,
"titleName": "Awesome Game",
"isUnlocked": false,
"description": "Explore every corner of the world.",
"mediaAssets": []
}
]
}
Simplified example of an Xbox Live Achievements API response.