rawg.io api client ⚔

Built with ❤︎ by orels1

Task Board

API Docs

What's new?

Installation

# with npm
npm i --save rawger

# or with yarn
yarn add rawger

Usage

Unauthenticated client

const Rawger = require('rawger');

// initialize rawger with default 60s cache
// you can supply a different timeout
// or use rawger.purgeCache(); to force-clear the cache altogether
// check Caching section of the docs to learn more
// ⚠️ starting with v1.1 you need to always await the init process
const rawger = await Rawger();
const { users } = rawger;

// get "Currently Playing" games for user
const playing = (await users('orels1').games('playing')).get();

// get count of owned games
const owned = (await users('orels1').games('owned')).count();

// get raw api response object for "Want to Play" games
const raw = (await users('orels1').games('toplay')).raw();

// get user profile
const profile = (await users('orels1').profile()).get();

// get next page for the paginated endpoints
const games = await (await users('orels1').games('owned')).next();
const nextGames = games.get();

// get user's collections
const collections = (await users('orels1').collections()).get();

// get user's reviews
const reviews = (await users('orels1').reviews()).get();

// Get games matching 'witcher'
const searchResults = (await games.search('witcher')).get();

// Get single game by slug
const searchResults = (await games.get('the-witcher-3-wild-hunt')).get();

Authenticated client

You can also initialize an authenticated client to perform such actions as game status updates, reviews publishing and so on.

const Rawger = require('rawger');

// make sure to `await` the init process
const rawger = await Rawger({
  email: '[email protected]',
  password: 'do-not-share-this'
});
const { users } = rawger;

// set FarCry 5 to "Currently Playing" for current account
await users('orels1').update().game('23585', { status: 'playing'});

Sections