### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game-list.md This is an example of how to make an HTTP GET request to the API to retrieve the game list for a system. Ensure you replace placeholders with your actual credentials and desired parameters. ```http https://retroachievements.org/API/API_GetGameList.php?i=1&h=1&f=1 ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-want-to-play-list.md Example of an HTTP GET request to retrieve a user's want-to-play list. Replace 'MaxMilyin' with the target username. ```http https://retroachievements.org/API/API_GetUserWantToPlayList.php?u=MaxMilyin ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-progress.md Example of how to call the Get User Progress API using an HTTP GET request. ```APIDOC ## GET /API/API_GetUserProgress.php ### Description Retrieves a given user's progress on a given list of games, targeted by a list of game IDs. ### Method GET ### Endpoint https://retroachievements.org/API/API_GetUserProgress.php ### Query Parameters #### Query Parameters - **y** (string) - Required - Your web API key. - **u** (string) - Optional - The target username or ULID. - **i** (string) - Required - The target game IDs, as a comma-separated value. ### Response #### Success Response (200) - **(object)** - An object where keys are game IDs and values contain progress details. - **NumPossibleAchievements** (integer) - The total number of achievements possible for the game. - **PossibleScore** (integer) - The total score possible for the game. - **NumAchieved** (integer) - The number of achievements the user has achieved. - **ScoreAchieved** (integer) - The score the user has achieved. - **NumAchievedHardcore** (integer) - The number of hardcore achievements the user has achieved. - **ScoreAchievedHardcore** (integer) - The score the user has achieved in hardcore mode. ### Response Example ```json { "1": { "NumPossibleAchievements": 23, "PossibleScore": 251, "NumAchieved": 23, "ScoreAchieved": 251, "NumAchievedHardcore": 23, "ScoreAchievedHardcore": 251 }, "2": { "NumPossibleAchievements": 22, "PossibleScore": 320, "NumAchieved": 22, "ScoreAchieved": 320, "NumAchievedHardcore": 22, "ScoreAchievedHardcore": 320 }, "3": { "NumPossibleAchievements": 23, "PossibleScore": 335, "NumAchieved": 23, "ScoreAchieved": 335, "NumAchievedHardcore": 23, "ScoreAchievedHardcore": 335 } } ``` ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-completed-games.md Example of how to make an HTTP GET request to the User Completed Games endpoint. ```http https://retroachievements.org/API/API_GetUserCompletedGames.php?u=MaxMilyin ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-progress.md Example of how to make an HTTP GET request to the User Specific Games Progress endpoint. ```http https://retroachievements.org/API/API_GetUserProgress.php?u=MaxMilyin&i=1,2,3 ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-claims.md This is an example of how to make an HTTP GET request to the User Claims endpoint. ```http https://retroachievements.org/API/API_GetUserClaims.php?u=Jamiras ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-game-rank-and-score.md Example of how to call the API using an HTTP GET request. ```APIDOC ## GET /API/API_GetUserGameRankAndScore.php ### Description Retrieves metadata about how a given user has performed/ranked on a given game, targeted by game ID. ### Endpoint https://retroachievements.org/API/API_GetUserGameRankAndScore.php ### Query Parameters #### Query Parameters - **y** (string) - Required - Your web API key. - **u** (string) - Optional - The target username or ULID. - **g** (integer) - Required - The target game ID. ### Response #### Success Response (200) - **User** (string) - The username of the target user. - **ULID** (string) - The ULID of the target user. - **UserRank** (integer) - The rank of the user for the game. - **TotalScore** (integer) - The total score achieved by the user for the game. - **LastAward** (string) - The timestamp of the last award received by the user for the game. #### Response Example ```json [ { "User": "WCopeland", "ULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "UserRank": 9, "TotalScore": 199, "LastAward": "2023-06-07 14:44:00" } ] ``` ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-set-requests.md Example of an HTTP GET request to retrieve user set requests. Replace 'MaxMilyin' with the target username or ULID. ```http GET https://retroachievements.org/API/API_GetUserSetRequests.php?u=MaxMilyin ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game-extended.md This is an example of the HTTP GET request to retrieve extended game details. Replace '1' with the desired game ID. ```http https://retroachievements.org/API/API_GetGameExtended.php?i=1 ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-completion-progress.md This is an example of a direct HTTP GET request to the API endpoint. Replace 'MaxMilyin' with the target username. ```http https://retroachievements.org/API/API_GetUserCompletionProgress.php?u=MaxMilyin ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-game-rank-and-score.md Example of an HTTP GET request to retrieve user game rank and score. ```http https://retroachievements.org/API/API_GetUserGameRankAndScore.php?g=14402&u=WCopeland ``` -------------------------------- ### Get User Points (HTTP) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-points.md This example demonstrates how to retrieve a user's points using a direct HTTP GET request. ```APIDOC ## GET /API/API_GetUserPoints.php ### Description A call to this endpoint will retrieve a given user's hardcore and softcore points. ### Method GET ### Endpoint https://retroachievements.org/API/API_GetUserPoints.php ### Parameters #### Query Parameters - **y** (string) - Required - Your web API key. - **u** (string) - Optional - The target username or ULID. ### Request Example https://retroachievements.org/API/API_GetUserPoints.php?u=Hexadigital ### Response #### Success Response (200) - **Points** (integer) - The user's total hardcore points. - **SoftcorePoints** (integer) - The user's total softcore points. #### Response Example ```json { "Points": 31299, "SoftcorePoints": 24264 } ``` ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-achievements-earned-on-day.md Example of how to make an HTTP GET request to retrieve achievements earned on a specific day. ```APIDOC ## GET /API/API_GetAchievementsEarnedOnDay.php ### Description Retrieves a list of achievements unlocked by a given user on a specified date. ### Method GET ### Endpoint https://retroachievements.org/API/API_GetAchievementsEarnedOnDay.php ### Query Parameters #### Query Parameters - **y** (string) - Required - Your web API key. - **u** (string) - Optional - The target username or ULID. - **d** (string) - Required - Date in YYYY-MM-DD format. ### Response #### Success Response (200) - **Date** (string) - The date and time the achievement was earned. - **HardcoreMode** (integer) - Indicates if the achievement was earned in hardcore mode (1 for true, 0 for false). - **AchievementID** (integer) - The unique identifier for the achievement. - **Title** (string) - The title of the achievement. - **Description** (string) - The description of the achievement. - **BadgeName** (string) - The name of the badge associated with the achievement. - **Points** (integer) - The points awarded for the achievement. - **Type** (null) - Placeholder for achievement type, currently null. - **Author** (string) - The username of the achievement's author. - **AuthorULID** (string) - The ULID of the achievement's author. - **GameTitle** (string) - The title of the game the achievement belongs to. - **GameIcon** (string) - The path to the game's icon. - **GameID** (integer) - The unique identifier for the game. - **ConsoleName** (string) - The name of the console the game is on. - **CumulScore** (integer) - The cumulative score for the achievement. - **BadgeURL** (string) - The URL to the achievement's badge. - **GameURL** (string) - The URL to the game's page. ### Response Example ```json [ { "Date": "2022-10-14 00:43:58", "HardcoreMode": 1, "AchievementID": 250780, "Title": "Play With Yourself", "Description": "Completed Rank F in the Monster Arena", "BadgeName": "277506", "Points": 5, "Type": null, "Author": "TheMysticalOne", "AuthorULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameTitle": "Dragon Quest VIII: Journey of the Cursed King", "GameIcon": "/Images/038649.png", "GameID": 2721, "ConsoleName": "PlayStation 2", "CumulScore": 5, "BadgeURL": "/Badge/277506.png", "GameURL": "/game/2721" } ] ``` ``` -------------------------------- ### Get User Points (Kotlin) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-points.md This example demonstrates how to retrieve user points using the official Kotlin client library. ```APIDOC ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getUserPoints( username = "Hexadigital" ) if (response is NetworkResponse.Success) { // handle the data val userPoints: GetUserPoints.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` ``` -------------------------------- ### Get All Systems Source: https://github.com/retroachievements/api-docs/blob/main/README.md Get the complete list of system ID and name pairs on the site. ```APIDOC ## GET /v1/get-console-ids ### Description Retrieves a list of all available systems with their corresponding IDs and names. ### Method GET ### Endpoint /v1/get-console-ids ``` -------------------------------- ### Get Game Summary (Kotlin Client Library) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game.md Example of how to fetch a game summary using the RetroAchievements API client library for Kotlin. ```kotlin import org.retroachievements.api.RetroCredentials import org.retroachievements.api.RetroClient import org.retroachievements.api.RetroInterface import org.retroachievements.api.responses.ErrorResponse import org.retroachievements.api.responses.getgame.GetGame import com.haroldadmin.network.NetworkResponse val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getGame( gameId = 14402 ) if (response is NetworkResponse.Success) { val game: GetGame.Response = response.body // Handle the game data } else if (response is NetworkResponse.Error) { val errorResponse: ErrorResponse? = response.body val internalError: Throwable? = response.error // Handle errors } ``` -------------------------------- ### Kotlin Client Library Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-most-recent-tickets.md Example of how to use the Kotlin client library to fetch the most recent tickets. ```APIDOC ## Kotlin Client Library ### Description This code snippet demonstrates how to use the RetroAchievements API client library in Kotlin to fetch the most recent tickets. ### Usage ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api // you may pass an offset or count to its parameters val response: NetworkResponse = api.getMostRecentTickets() if (response is NetworkResponse.Success) { // handle the data val tickets: GetMostRecentTickets.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` ``` -------------------------------- ### Get User Points (NodeJS) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-points.md This example shows how to fetch user points using the official NodeJS client library. ```APIDOC ```ts import { buildAuthorization, getUserPoints } from "@retroachievements/api"; // First, build your authorization object. const username = ""; const webApiKey = ""; const authorization = buildAuthorization({ username, webApiKey }); // Then, make the API call. const userPoints = await getUserPoints(authorization, { username: "Hexadigital", }); ``` ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-achievements-earned-on-day.md Example of an HTTP GET request to retrieve achievements earned on a specific date. Requires username and date as query parameters. ```http https://retroachievements.org/API/API_GetAchievementsEarnedOnDay.php?u=MaxMilyin&d=2022-10-14 ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-recent-achievements.md Example of an HTTP GET request to retrieve recent user achievements. Replace 'Scott' with the target username or ULID. ```http https://retroachievements.org/API/API_GetUserRecentAchievements.php?u=Scott ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-users-following-me.md This is an example of the JSON response structure you can expect when calling the API to get users following you. It includes pagination details and a list of users. ```json { "Count": 20, "Total": 120, "Results": [ { "User": "zuliman92", "ULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "Points": 1882, "PointsSoftcore": 258, "AmIFollowing": true } // ... ] } ``` -------------------------------- ### HTTP GET Request for User Summary Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-summary.md This is an example of how to make an HTTP GET request to the User Summary endpoint. Ensure you include your web API key and specify the target user. ```http https://retroachievements.org/API/API_GetUserSummary.php?u=xelnia&g=1&a=2 ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-recently-played-games.md This is an example of a direct HTTP GET request to the API endpoint for retrieving a user's recently played games. Replace 'MaxMilyin' with the target username. ```http https://retroachievements.org/API/API_GetUserRecentlyPlayedGames.php?u=MaxMilyin ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-progress.md Example of the JSON response structure when requesting user progress for multiple games. ```json { "1": { "NumPossibleAchievements": 23, "PossibleScore": 251, "NumAchieved": 23, "ScoreAchieved": 251, "NumAchievedHardcore": 23, "ScoreAchievedHardcore": 251 }, "2": { "NumPossibleAchievements": 22, "PossibleScore": 320, "NumAchieved": 22, "ScoreAchieved": 320, "NumAchievedHardcore": 22, "ScoreAchievedHardcore": 320 }, "3": { "NumPossibleAchievements": 23, "PossibleScore": 335, "NumAchieved": 23, "ScoreAchieved": 335, "NumAchievedHardcore": 23, "ScoreAchievedHardcore": 335 } } ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-achievements-earned-between.md Example of an HTTP GET request to retrieve achievements earned between two epoch timestamps. Ensure you replace placeholders with your actual API key and desired user. ```http https://retroachievements.org/API/API_GetAchievementsEarnedBetween.php?u=Jamiras&f=1641054603&t=1641659403 ``` -------------------------------- ### Get Game Summary (Node.js Client Library) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game.md Example of how to fetch a game summary using the RetroAchievements API client library for Node.js. ```typescript import { buildAuthorization, getGame } from "@retroachievements/api"; const username = ""; const webApiKey = ""; const authorization = buildAuthorization({ username, webApiKey }); const game = await getGame(authorization, { gameId: 14402, }); console.log(game); ``` -------------------------------- ### Get User Points with Kotlin Client Library Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-points.md Utilize the api-kotlin client library to retrieve user points. This example shows how to initialize the API client and handle both successful responses and errors. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getUserPoints( username = "Hexadigital" ) if (response is NetworkResponse.Success) { // handle the data val userPoints: GetUserPoints.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` -------------------------------- ### Get Game Metadata (Kotlin) Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Example of fetching basic metadata for a specific game using the Kotlin client library. ```APIDOC ## Get Game Metadata (Kotlin) ### Description Fetches basic metadata for a specified game using its ID. ### Method Signature `api.getGame(gameId: Int)` ### Parameters - **gameId** (Int) - Required - The ID of the game to retrieve. ### Response - **Success Response** (`NetworkResponse`): Contains the game metadata upon success. ### Code Example ```kotlin // Assuming 'api' is an initialized RetroInterface instance // This returns basic metadata about the game with ID 14402 val response: NetworkResponse = api.getGame( gameId = 14402 ) ``` ``` -------------------------------- ### Get User Claims with Kotlin Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-claims.md Utilize the api-kotlin library to retrieve user claims. This example shows how to instantiate the client, make the call, and handle both success and error responses. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getUserClaims( username = "Jamiras" ) if (response is NetworkResponse.Success) { // handle the data val claims: GetUserClaims.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` -------------------------------- ### NodeJS Client Library Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-most-recent-tickets.md Example of how to use the NodeJS client library to fetch the most recent tickets. ```APIDOC ## NodeJS Client Library ### Description This code snippet demonstrates how to use the `@retroachievements/api` library in NodeJS to fetch the most recent tickets. ### Usage ```ts import { buildAuthorization, getTicketData } from "@retroachievements/api"; // First, build your authorization object. const username = ""; const webApiKey = ""; const authorization = buildAuthorization({ username, webApiKey }); // Then, make the API call. const mostRecentTickets = await getTicketData(authorization, { count: 10, offset: 0, }); ``` ``` -------------------------------- ### NodeJS Client Library Installation Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Install the official RetroAchievements API client library for NodeJS using npm. ```APIDOC ## Install NodeJS Client Library ### Description Installs the RetroAchievements API client library for JavaScript/TypeScript/NodeJS. ### Package Manager npm ### Command ```bash npm install --save @retroachievements/api ``` ``` -------------------------------- ### Get Top Ten Users (Kotlin) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-top-ten-users.md Example of how to fetch the top ten users using the RetroAchievements API client library in Kotlin. ```APIDOC ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getTopTenUsers() if (response is NetworkResponse.Success) { // handle the data val topUsers: GetTopTenUsers.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` ``` -------------------------------- ### Fetch Game Leaderboards with Node.js Client Library Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game-leaderboards.md This Node.js example demonstrates how to authenticate and call the getGameLeaderboards function. Ensure you have the @retroachievements/api library installed. ```typescript import { buildAuthorization, getGameLeaderboards, } from "@retroachievements/api"; // First, build your authorization object. const username = ""; const webApiKey = ""; const authorization = buildAuthorization({ username, webApiKey }); // Then, make the API call. const gameLeaderboards = await getGameLeaderboards(authorization, { gameId: 14402, }); ``` -------------------------------- ### Get Claims with Kotlin Client Library Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-claims.md Utilize the Kotlin client library for API interactions. This example demonstrates handling both successful responses and potential errors. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getClaims( claimKind = 2 ) if (response is NetworkResponse.Success) { // handle the data val claims: GetClaims.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-claims.md This is an example of the JSON response structure you can expect from the User Claims endpoint. ```json [ { "ID": 11161, "User": "Jamiras", "ULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameID": 18644, "GameTitle": "~Unlicensed~ Hi-Leg Fantasy", "GameIcon": "/Images/083201.png", "ConsoleID": 76, "ConsoleName": "PC Engine CD", "ClaimType": 0, "SetType": 0, "Status": 0, "Extension": 0, "Special": 0, "Created": "2023-10-16 02:25:34", "DoneTime": "2024-01-16 02:25:34", "Updated": "2023-10-16 02:25:34", "UserIsJrDev": 0, "MinutesLeft": -58300 } ] ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-achievements-earned-on-day.md Example of the JSON response structure for achievements earned on a specific day. ```json [ { "Date": "2022-10-14 00:43:58", "HardcoreMode": 1, "AchievementID": 250780, "Title": "Play With Yourself", "Description": "Completed Rank F in the Monster Arena", "BadgeName": "277506", "Points": 5, "Type": null, "Author": "TheMysticalOne", "AuthorULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameTitle": "Dragon Quest VIII: Journey of the Cursed King", "GameIcon": "/Images/038649.png", "GameID": 2721, "ConsoleName": "PlayStation 2", "CumulScore": 5, "BadgeURL": "/Badge/277506.png", "GameURL": "/game/2721" } // ... ] ``` -------------------------------- ### Start Development Server Source: https://github.com/retroachievements/api-docs/blob/main/README.md Run this command to start the local development server for the documentation site. Access it at http://localhost:5173/. ```bash pnpm dev ``` -------------------------------- ### Node.js Client Library Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-comments.md Example of the JSON response structure as returned by the Node.js client library. ```json { "count": 4, "total": 4, "results": [ { "user": "PlayTester", "ulid": "00003EMFWR7XB8SDPEHB3K56ZQ", "submitted": "2024-07-31T11:22:23.000000Z", "commentText": "Comment 1" } // ... ] } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/retroachievements/api-docs/blob/main/README.md Use this command to install all necessary project dependencies before running the development server or building the project. ```bash pnpm install ``` -------------------------------- ### Kotlin Client Library for Game Hashes Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game-hashes.md This Kotlin example shows how to set up credentials, initialize the RetroClient, and make a call to getGameHashes. It includes basic error handling for network responses. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getGameHashes( gameId = 14402 ) if (response is NetworkResponse.Success) { // handle the data val gameHashes: GetGameHashes.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` -------------------------------- ### Initialize API Client (Kotlin) Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Example of how to initialize the RetroAchievements API client in Kotlin using your credentials. ```APIDOC ## Initialize API Client (Kotlin) ### Description Initializes the RetroAchievements API client with your credentials for use in Kotlin applications. ### Classes - `RetroCredentials`: Used to store your username and web API key. - `RetroClient`: The main client class to interact with the API. - `RetroInterface`: The interface defining available API methods. ### Code Example ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api // Access the API interface via the `api` property. ``` ``` -------------------------------- ### Install NodeJS Client Library Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Install the official RetroAchievements API client library for NodeJS using npm. ```bash npm install --save @retroachievements/api ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-recent-game-awards.md This is an example of an HTTP GET request to the API endpoint for retrieving recent game awards. The URL includes the base path. ```http https://retroachievements.org/API/API_GetRecentGameAwards.php ``` -------------------------------- ### Start Player Session (`startsession`) Source: https://context7.com/retroachievements/api-docs/llms.txt Initiates a player session for a given game, returning any existing hardcore unlocks for that game. ```APIDOC ## Start Player Session (`startsession`) ### Description Must be called when a player begins playing a game. This endpoint returns the user's existing hardcore unlocks for the specified game. ### Method `POST` ### Endpoint `https://retroachievements.org/dorequest.php?u={YourUsername}&t={YourToken}&r=startsession&g={YOUR_GAME_ID}&k={TheirUsername}` ### Headers - **User-Agent**: Required. Format: `{Client}/{version} ({platform})` ### Parameters #### Query Parameters - **u** (string) - Required - Your RetroAchievements username. - **t** (string) - Required - Your Connect API token. - **r** (string) - Required - Must be `startsession`. - **g** (string) - Required - The ID of the game. - **k** (string) - Required - The username of the player whose session is starting. ### Response #### Success Response (200) - **Success** (boolean) - Indicates if the session was started successfully. - **HardcoreUnlocks** (array) - An array of hardcore unlock objects, each containing `ID` and `When`. - **ServerNow** (number) - The current server timestamp. ### Request Example ```bash curl -X POST -H "User-Agent: HorizonXI/1.0.0 (Server)" \ "https://retroachievements.org/dorequest.php?u=YourUsername&t=YourToken&r=startsession&g=YOUR_GAME_ID&k=TheirUsername" # { "Success": true, "HardcoreUnlocks": [{ "ID": 141, "When": 1591132445 }], "ServerNow": 1704076711 } ``` ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-want-to-play-list.md Example of a successful HTTP response containing the user's want-to-play list. Includes count, total, and a list of game results. ```json { "Count": 100, "Total": 1287, "Results": [ { "ID": 20246, "Title": "~Hack~ Knuckles the Echidna in Sonic the Hedgehog", "ImageIcon": "/Images/074560.png", "ConsoleID": 1, "ConsoleName": "Genesis/Mega Drive", "PointsTotal": 1500, "AchievementsPublished": 50 } // ... ] } ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-claims.md This is an example of the JSON response structure you can expect when calling the Get Claims API. It includes details about each claim. ```json [ { "ID": 11245, "User": "kmpers", "ULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameID": 24541, "GameTitle": "GP World", "GameIcon": "/Images/076324.png", "ConsoleID": 33, "ConsoleName": "SG-1000", "ClaimType": 0, "SetType": 1, "Status": 1, "Extension": 0, "Special": 1, "Created": "2023-10-27 22:30:49", "DoneTime": "2023-10-27 23:21:12", "Updated": "2023-10-27 23:21:12", "UserIsJrDev": 0, "MinutesLeft": -173762 } // ... ] ``` -------------------------------- ### Fetch Game Leaderboards with Kotlin Client Library Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-game-leaderboards.md This Kotlin example shows how to initialize the RetroClient and call the getGameLeaderboards function. It includes basic error handling for network responses. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getGameLeaderboards( gameId = 14402 ) if (response is NetworkResponse.Success) { // handle the data val gameLeaderboards: GetGameLeaderboards.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` -------------------------------- ### Kotlin Client Library Installation (Gradle) Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Instructions for adding the RetroAchievements API client library for Kotlin to your Gradle project. ```APIDOC ## Install Kotlin Client Library (Gradle) ### Description Adds the RetroAchievements API client library for Kotlin to your project using Gradle. ### Repository Configuration Add the jitpack.io repository to your root build.gradle file's `dependencyResolutionManagement` section: ```groovy dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() maven { url 'https://jitpack.io' } } } ``` ### Dependency Configuration Add the following dependency to your module's `build.gradle` file: ```groovy dependencies { implementation 'com.github.RetroAchievements:api-kotlin:1.0.1' } ``` ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-game-ticket-stats.md This is an example of an HTTP GET request to retrieve ticket stats for a game. Ensure you replace '1' with the desired game ID. ```http https://retroachievements.org/API/API_GetTicketData.php?g=1 ``` -------------------------------- ### HTTP Request Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-achievement-distribution.md Example of an HTTP GET request to retrieve achievement distribution data for a game. The 'h' parameter filters for hardcore unlocks. ```http https://retroachievements.org/API/API_GetAchievementDistribution.php?i=14402&h=1 ``` -------------------------------- ### Get Achievement Ticket Stats HTTP Request Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-achievement-ticket-stats.md This example demonstrates how to fetch achievement ticket stats using a direct HTTP GET request. ```APIDOC ## GET /API/API_GetTicketData.php ### Description Retrieves ticket statistics for a specific achievement. ### Method GET ### Endpoint https://retroachievements.org/API/API_GetTicketData.php ### Query Parameters - **y** (string) - Required - Your web API key. - **a** (integer) - Required - The target achievement ID to fetch ticket stats for. ### Response #### Success Response (200) - **AchievementID** (integer) - The ID of the achievement. - **AchievementTitle** (string) - The title of the achievement. - **AchievementDescription** (string) - The description of the achievement. - **AchievementType** (string) - The type of the achievement (e.g., progression). - **URL** (string) - A URL pointing to the achievement's ticket page. - **OpenTickets** (integer) - The number of open tickets for the achievement. ### Response Example ```json { "AchievementID": 284759, "AchievementTitle": "The End of The Beginning", "AchievementDescription": "Receive the Package from the King of Baron and begin your quest to the Mist Cavern", "AchievementType": "progression", "URL": "https://retroachievements.org/achievement/284759/tickets", "OpenTickets": 1 } ``` ``` -------------------------------- ### HTTP Response Example for GetTicketData Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-most-recent-tickets.md This is an example of the JSON response structure when calling the API to get ticket data. It includes details about recent tickets and counts. ```json { "RecentTickets": [ { "ID": 64866, "AchievementID": 323665, "AchievementTitle": "DEFAULT SETTINGS CHECK", "AchievementDesc": "Normal or Hard difficulty, any character but \"Man\", any buster charge. All other settings OFF.", "AchievementType": null, "Points": 0, "BadgeName": "361407", "AchievementAuthor": "WCopeland", "AchievementAuthorULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameID": 24453, "ConsoleName": "Mega Drive", "GameTitle": "~Homebrew~ Mega Man: The Sequel Wars - Episode Red", "GameIcon": "/Images/074329.png", "ReportedAt": "2024-01-10 22:31:54", "ReportType": 2, "Hardcore": 1, "ReportNotes": "asdfasdfasdfasdf\nRetroAchievements Hash: bff0eb90c2006edade14063d4a2d13cf\nEmulator: RALibRetro (123123)\nEmulator Version: 123", "ReportedBy": "WCopeland", "ReportedByULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "ResolvedAt": null, "ResolvedBy": null, "ResolvedByULID": null, "ReportState": 1, "ReportStateDescription": "Open", "ReportTypeDescription": "Did not trigger" } ], "OpenTickets": 1109, "URL": "https://retroachievements.org/tickets" } ``` -------------------------------- ### Kotlin Client Library Installation (Maven) Source: https://github.com/retroachievements/api-docs/blob/main/docs/getting-started.md Instructions for adding the RetroAchievements API client library for Kotlin to your Maven project. ```APIDOC ## Install Kotlin Client Library (Maven) ### Description Adds the RetroAchievements API client library for Kotlin to your project using Maven. ### Repository Configuration Add the jitpack.io repository to your `pom.xml`'s `` section: ```xml jitpack.io https://www.jitpack.io ``` ### Dependency Configuration Add the following dependency to your `pom.xml`'s `` section: ```xml com.github.RetroAchievements api-kotlin 1.0.1 ``` ``` -------------------------------- ### Start Player Session Source: https://github.com/retroachievements/api-docs/blob/main/docs/connect/standalone.md Initiate a player session by sending an HTTP POST request to the dorequest.php endpoint. This requires your username, Connect API token, game ID, and the player's RA username. Ensure the player has already linked their account. ```http POST https://retroachievements.org/dorequest.php?u=YourUsername&t=YourConnectToken&r=startsession&g=YourCoreGameId&k=TheirUsername ``` -------------------------------- ### HTTP Response Example Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-set-requests.md Example of a successful HTTP response containing the user's requested sets, total requests, and points needed for the next request. ```json { "RequestedSets": [ { "GameID": 8149, "Title": "Jurassic Park Institute Tour: Dinosaur Rescue", "ConsoleID": 5, "ConsoleName": "Game Boy Advance", "ImageIcon": "/Images/000001.png" }, { "GameID": 600, "Title": "Psycho Pinball", "ConsoleID": 1, "ConsoleName": "Genesis/Mega Drive", "ImageIcon": "/Images/039797.png" }, { "GameID": 1, "Title": "Sonic the Hedgehog", "ConsoleID": 1, "ConsoleName": "Genesis/Mega Drive", "ImageIcon": "/Images/085573.png" } ], "TotalRequests": 5, "PointsForNext": 5000 } ``` -------------------------------- ### GET User Game Leaderboards HTTP Request Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-game-leaderboards.md Example of an HTTP GET request to retrieve user game leaderboards. Requires API key, game ID, and user identifier. ```http https://retroachievements.org/API/API_GetUserGameLeaderboards.php?i=1&u=zuliman92 ``` -------------------------------- ### API Endpoint Example with API Key Source: https://github.com/retroachievements/api-docs/blob/main/docs/index.md This example shows how to access an API endpoint by providing your RetroAchievements account's API key as the 'y' query parameter. Ensure you replace '[your_key]' with your actual API key. ```http https://retroachievements.org/API/API_GetAchievementOfTheWeek.php?&y=[your_key] ``` -------------------------------- ### HTTP Response Example for Active Claims Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-active-claims.md This is an example of the JSON response structure you can expect when calling the Get Active Claims endpoint. Note the 'MinutesLeft' field, where a negative value indicates an expired claim. ```json [ { "ID": 11246, "User": "WanderingHeiho", "ULID": "00003EMFWR7XB8SDPEHB3K56ZQ", "GameID": 26971, "GameTitle": "~Homebrew~ No Place To Hide", "GameIcon": "/Images/084916.png", "ConsoleID": 18, "ConsoleName": "Nintendo DS", "ClaimType": 0, "SetType": 0, "Status": 0, "Extension": 0, "Special": 0, "Created": "2023-10-27 23:27:16", "DoneTime": "2024-01-27 23:27:16", "Updated": "2023-10-27 23:27:16", "UserIsJrDev": 0, "MinutesLeft": -41266 // Negative minutes left means the claim is expired. } // ... ] ``` -------------------------------- ### Get Ticket by ID (Kotlin) Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-ticket-data/get-ticket-by-id.md Example of how to retrieve ticket metadata using the Kotlin client library. ```APIDOC ## getTicket ### Description Fetches ticket metadata for a single achievement ticket using the Kotlin client library. ### Method Signature `api.getTicket(ticketId: Int): NetworkResponse` ### Parameters #### `ticketId` (Int) - Required The ID of the ticket to retrieve. ### Response #### Success Response - **body** (GetTicketData.Response) - The ticket data if the request is successful. #### Error Response - **body** (ErrorResponse?) - The error response body if the server returns an error. - **error** (Throwable?) - The internal error if the API had a local error. ### Usage Example ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getTicket( ticketId = 12345 ) if (response is NetworkResponse.Success) { // handle the data val ticket: GetTicketData.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ``` ``` -------------------------------- ### Kotlin Client Library Usage Source: https://github.com/retroachievements/api-docs/blob/main/docs/v1/get-user-want-to-play-list.md Example of using the Kotlin client library to fetch a user's want-to-play list. Handles success and error responses from the API. ```kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api val response: NetworkResponse = api.getUserWantToPlayList( username = "MaxMilyin", ) if (response is NetworkResponse.Success) { // handle the data val wantToPlayList: GetUserWantToPlayList.Response = response.body } else if (response is NetworkResponse.Error) { // if the server returns an error it be found here val errorResponse: ErrorResponse? = response.body // if the api (locally) had an internal error, it'll be found here val internalError: Throwable? = response.error } ```