- Aligns with the official RetroAchievements web API.
- Is promise-based.
- Supports Node environments.
- Supports browsers.
- Supports TypeScript.
- Small, <10Kb.
- Getting started
- Examples
- Initializing the client
- Top ten users by points
- Get all console IDs
- Get list of all registered Gameboy games
- Basic game information for Super Mario Land (GB)
- Full game information for Super Mario Land (GB)
- Complete summary of Scott's progress for game ID 3
- Scott's global rank and score
- Scott's 10 most recently played games
- Scott's progress on games with IDs 2, 3, and 75
- Scott's user summary
- Achievements earned by Scott on January 4th, 2014
- Scott's game completion progress
npm install --save retroachievements-js
OR
yarn add retroachievements-js
Node 10 and above are officially supported. The package can be imported via:
const RetroAchievementsClient = require('retroachievements-js');
You can use import
syntax to utilize the package in your app. This library provides its own type definitions. "It just works", no need to install anything from @types
.
import { RetroAchievementsClient } from 'retroachievements-js';
All methods in the API are async and return a native Promise.
These methods can be used with the native Promise API or the more modern async/await syntax.
// Native Promise API.
client.getTopTen().then(topTen => {
console.log({ topTen });
});
// async/await syntax.
const logTopTenUsers = async () => {
const topTen = await client.getTopTen();
console.log({ topTen });
};
To initialize the client, you will need your username and your RetroAchievements Web API key. To get your Web API key, visit your control panel on the RetroAchievements website.
You can initialize the client like so:
import { RetroAchievementsClient } from 'retroachievements-js';
const client = new RetroAchievementsClient({
userName: 'MyUserName', // this is your actual account name on the site
apiKey: 'MyApiKey'
});
Please note if you are using this library in the browser then your API key will be exposed. This is not destructive, as the API is read-only, but that could change at any time. For this reason, I recommend only using the library on the server where your API key can be kept a secret.
const printTopTenUsers = async () => {
const topTen = await client.getTopTenUsers();
console.log({ topTen });
};
const printAllConsoleIds = async () => {
const allConsoleIds = await client.getConsoleIds();
console.log({ allConsoleIds });
};
const printAllGameboyGames = async () => {
const allGameboyGames = await client.getGameListByConsoleId(4);
console.log({ allGameboyGames });
};
const printGameInfo = async () => {
const superMarioLandInfo = await client.getGameInfoByGameId(504);
console.log({ superMarioLandInfo });
};
const printExtendedGameInfo = async () => {
const superMarioLandExtendedInfo = await client.getExtendedGameInfoByGameId(
504
);
console.log({ superMarioLandExtendedInfo });
};
const printUserGameProgress = async () => {
const userGameProgress = await client.getUserProgressForGameId('Scott', 3);
console.log({ userGameProgress });
};
const printUserGlobalRankAndScore = async () => {
const userRankAndScore = await client.getUserRankAndScore('Scott');
console.log({ userRankAndScore });
};
const printUserRecentGames = async () => {
const userRecentGames = await client.getUserRecentlyPlayedGames('Scott', 10);
console.log({ userRecentGames });
};
const printUserMultipleGameProgress = async () => {
const userProgress = await client.getUserProgressForGames('Scott', [
2,
3,
75
]);
console.log({ userProgress });
};
const printUserSummary = async () => {
const userSummary = await client.getUserSummary('Scott');
console.log({ userSummary });
};
const printUserAchievementsOnDate = async () => {
const achievementsOnDate = await client.getUserAchievementsEarnedOnDate(
'Scott',
new Date('01-04-2014')
);
console.log({ achievementsOnDate });
};
const printUserCompletionProgress = async () => {
const completionProgress = await client.getUserGameCompletionStats('Scott');
console.log({ completionProgress });
};