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

modio.js

v1.1.3-c

Published

A nodejs library to interact with mod.io API. Very unfinished.

Downloads

53

Readme

modio.js

This is currently a very unfinished library. Docs are still very basic, and most API features you'll get using libraries for other languages (python, cli) are not here. Made this because there were no other libraries for using the mod.io API for nodejs, and I decided to publish it because other people might be looking for a module to use mod.io API too.

Usage

Setting API key
const modio = require('modio.js');

modio.setAPIKey('your-api-key'); // Get an API key at mod.io/apikey
Setting OAuth key
const modio = require('modio.js');

modio.setOAuthKey('your-oauth-key'); // Get an OAuth key at mod.io/apikey
Using Email Exchange
// Api key is needed.
const message = await modio.emailRequest('[email protected]');

// The user has to input the security code, so use whatever you use for getting user input.
const code = (await inquirer.prompt({type: 'input', name: 'oauth', message: 'Input the OAuth key you got.'})).oauth;

// Returns an Access Token class.
const accesstoken = await modio.emailExchange(code);
Downloading a mod
await modio.downloadMod('@game', '@mod', 'platform', 'outputpath'); //  Uses ID's like'@bonelab', '@m60'. File id's are not supported yet, but will be in a future update.
Getting all games
const games = await modio.getGames();
Getting a specific game
const game = await modio.getGame(id); // ID is same as shown in the mod download example ('@bonelab')
Getting all mods for a game
const mods = await modio.getMods(game); // Game is just @game, ex. '@bonelab'
Getting a specific mod
const mod = await modio.getMod(game, mod); // Game: @game (ex. '@bonelab'), mod: @mod (ex. '@m60')
Getting a mod's files
const modfiles = await modio.getModfiles(game, mod); // Extra arg: customErrorHandler. This arg is a function that handles mod request and modfile request errors. It gets the gameid, modid, res json, modfile res json and firstCall bool sent in. firstCall is an internal arg, which is passed in as false. Pass this in as the 4th argument to getModfiles if you decide to re-call getModfiles.
Getting a specific platform's mod files
const modfile = await modio.getModfile(game, mod, platform); // Game: @game (ex. '@bonelab'), mod: @mod (ex. '@m60'), platform: 'platform', ex. 'windows'
Getting comments on a mod
const comments = await modio.getModComments(game ,mod);
Getting a mod's dependencies
const dependencies = await modio.getModDependencies(game, mod);

OAuth is needed for the following functions.

Getting all subscribed mods
const mods = await modio.getSubscriptions();
Subscribing and unsubscribing from a mod
const subscribed = await modio.subscribeTo('@game', '@mod');
const unsubscribed = await modio.unsubscribeFrom('@game', '@mod');
Adding a rating to a mod
const message = await modio.addRating('@game', '@mod', rating) // Rating can be -1, 0 or 1. -1 is negative, 0 removes previous rating and 1 is positive.
Parsing a URL into game and mod
const parsedUrl = modio.parseUrl('https://mod.io/g/bonelab/m/m60'); // Parses url into an object containing game and mod. These are the game and mod params you need for most other functions.
const game = parsedUrl.game; // bonelab
const mod = parsedUrl.mod; // m60

Exposed variables

Exposed variables are: exposedInfo

exposedInfo contains booleans for whether or not both types of keys have been set.

Extra info

You'll likely be able to see newer versions on Github, as it's easier for me to update singular files there.

Changelog

Fix emailExchange checking the wrong variable