Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including rawger with all npm packages installed. Try it out:

var rawger = require("rawger")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

rawger v1.3.2

RAWG.io api client library

rawger

⚔ rawg.io api client ⚔
An easy to use client with built-in caching

Known Vulnerabilities

Built with ❤︎ by orels1

Installation

# with npm
npm i --save rawger

#with yarn
yarn add rawger

Documentation

Full documentation is available here

Usage Examples

Check examples folder for more usage examples

Unauthenticated client

const Rawger = require('rawger');

// initialize rawger with default 60s cache
// you can supply a different timeout (check examples folder)
// or use rawger.purgeCache(); to force-clear the cache altogether
// ⚠ 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();

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: 'some@email.com',
  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'});

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free