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

impequid-api

v0.0.1

Published

API to easily interact with impequid.

Downloads

4

Readme

Impequid API

A JavaScript/Node.js API to easily interact with Impequid.

Works best with WebPack or Node.js.

default class ImpequidAPI ({token, server='impequid.com', port=443, secure=true, debug=false})

Completely Promise-based, making it easy to interact with it, especially using yield and await.

import ImpequidAPI from 'impequid-api';
const iqa = new ImpequidAPI({token});

The following API method examples assume the above code is present.

In addition to that, they also omit this:

.catch(error => {
	console.error('something went wrong', error);
});

If you want or need error handling, you should definitely not omit that code.

verify + [none]

iqa.verify().then({isValid, userId} => {
	console.log(`Token is ${isValid ? '' : 'not '}valid`);
});

getUser + [user.id, user.name]

Beware that usernames may change. If you want to store information about a user, store it using the userId and impequidServer.

Depending on your permissions you may get less information.

iqa.getUser().then(user => {
	// Object user
	// String user.name [user.name]
	// String user.id [user.id] (usually convertable to Mongo's ObjectId)
});

getBackgroundToken + [any:background]

Fetch a background-access token from the server. This token can be used until the user revokes it and never gets IP-blocked.

The permission scope of a background-access token is completely separate from a client-access token.

For example: if you want to notify users about changes in the background, you should request the background.notify permission.

Tip: You can easily spot a background token, because it begins with the letter d, while the normal token begins with a n.

iqa.getBackgroundToken().then(token => {
	// String token
	// you may switch to the background token
	iqa.token = token;
});

get/set token + [none]

Gets or sets the used token. Useful if you want to switch to a background-token or if you want to use one ImpequidAPI instance for multiple users.

iqa.token = token;
console.log(iqa.token);

notify (Object options) + [notify]

Sends a notification to the user.

iqa.notify({
	message: 'Something you want the user to know',
	priority: -1, // low = -1, normal = 0, high = 1
	url: 'https://:appServer/api/redirect/:someToken'
	// You can use the above URL to instantly trigger an action when the user clicks the link
}).then(() => {
	// it worked
});

getPermissions + [none]

Retrieves all permissions associated to the token.

iqa.getPermissions().then(permissions => {
	// Object permissions
	// Example:
	//	{
	//		notify: true,
	//		user: {
	//			id: true
	//		},
	//		background: true
	//	}
	// note that `user: true` also grants user.id
	// see exported function hasPermission to easily check
	// for a particular permission
});

requestPermissions + [none]

Allows you to request new permissions. If you set a permission to false it will get disabled for your app.

The following example will request user.name permissions for the normal and background tokens. It will also disable the background.notify permission.

When requesting permissions, it's recommended to be as specific as possible, since you will otherwise get unnecessary permissions and users are more likely to decline your request.

iqa.requestPermissions({
	user: {
		name: true
	},
	background: {
		user: {
			name: true,
			id: true
		},
		notify: false
	}
})

isBackground + [none]

const isBackground = iqa.isBackground();
console.log(`API is ${isBackground ? '' : 'not '}running in background mode.`).

class ServiceProvider ({server='services.impequid.com', cacheDuration=60000, secure=true, port=443, debug=false})

import {ServiceProvider} from 'impequid-api';
const isp = new ServiceProvider();
isp.get('dns.smartfl.at').then(service => {
	console.log(service);
}).catch(error => {
	console.error('could not fetch service data');
});