npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

retroachievements-js

v1.4.0

Published

<h1 align="center"> retroachievements-js </h1>

Downloads

50

Readme

Features

Contents

Getting started

Install

npm install --save retroachievements-js

OR

yarn add retroachievements-js

Usage with Node

Node 10 and above are officially supported. The package can be imported via:

const RetroAchievementsClient = require('retroachievements-js');

Usage with TypeScript

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';

Understanding the Promise-based API

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 });
};

Examples

Initializing the Client

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.

Top ten users by points

const printTopTenUsers = async () => {
  const topTen = await client.getTopTenUsers();
  console.log({ topTen });
};

Get all console IDs

const printAllConsoleIds = async () => {
  const allConsoleIds = await client.getConsoleIds();
  console.log({ allConsoleIds });
};

Get list of all registered Gameboy games

const printAllGameboyGames = async () => {
  const allGameboyGames = await client.getGameListByConsoleId(4);
  console.log({ allGameboyGames });
};

Basic game information for Super Mario Land (GB)

const printGameInfo = async () => {
  const superMarioLandInfo = await client.getGameInfoByGameId(504);
  console.log({ superMarioLandInfo });
};

Full game information for Super Mario Land (GB)

const printExtendedGameInfo = async () => {
  const superMarioLandExtendedInfo = await client.getExtendedGameInfoByGameId(
    504
  );

  console.log({ superMarioLandExtendedInfo });
};

Complete summary of Scott's progress for game ID 3

const printUserGameProgress = async () => {
  const userGameProgress = await client.getUserProgressForGameId('Scott', 3);
  console.log({ userGameProgress });
};

Scott's global rank and score

const printUserGlobalRankAndScore = async () => {
  const userRankAndScore = await client.getUserRankAndScore('Scott');
  console.log({ userRankAndScore });
};

Scott's 10 most recently played games

const printUserRecentGames = async () => {
  const userRecentGames = await client.getUserRecentlyPlayedGames('Scott', 10);
  console.log({ userRecentGames });
};

Scott's progress on games with IDs 2, 3, and 75

const printUserMultipleGameProgress = async () => {
  const userProgress = await client.getUserProgressForGames('Scott', [
    2,
    3,
    75
  ]);

  console.log({ userProgress });
};

Scott's user summary

const printUserSummary = async () => {
  const userSummary = await client.getUserSummary('Scott');
  console.log({ userSummary });
};

Achievements earned by Scott on January 4th, 2014

const printUserAchievementsOnDate = async () => {
  const achievementsOnDate = await client.getUserAchievementsEarnedOnDate(
    'Scott',
    new Date('01-04-2014')
  );

  console.log({ achievementsOnDate });
};

Scott's game completion progress

const printUserCompletionProgress = async () => {
  const completionProgress = await client.getUserGameCompletionStats('Scott');
  console.log({ completionProgress });
};