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 🙏

© 2025 – Pkg Stats / Ryan Hefner

easy-api-js

v1.3.1

Published

Easy to use REST API functionality for browsers

Readme

easy-api-js

Easy to use REST calls from browsers - Using the browser fetch API

When not using a buildtool like browserify / webpack and you want to support legacy browsers you'll need polyfills for: fetch, Promise, and Object.assign

npm install easy-api-js

Usage:

// Import
var easyAPI = require('easy-api-js');

// Define routes
// The params in the route will be replaced with values from the 
// data object that you'll pass when calling a function
var routes = {
    'users.save':   '/users/save/:id',
    'users.delete': '/users/delete/:id',
    'users.fetch':    '/users/:id'
};

// Define API functions
var userAPI = {
	// You can specify a domain function as an object: 
    // this will use the route users.save automatically
    save: {
        method: 'POST',
        //route: 'users.save' // optional
        options: { // Optional options applied only to this method call
            parse: 'blob'
        }
    },

	// You can define a function instead of a configuration object
	// to handle calls yourself:    
    //save: function(data) {
    //    let route = this.getRoute('users.save', data});
    //    return this.post(route, data);
    //},

    fetch: function(data) {
        var route = this.getRoute('users.fetch', data);
        return this.get(route);
    }
};

// Create the API
var API = new easyAPI('//api.somedomain.com', {
    routes: routes,
    domains: {users: userAPI},
    options: { // Optional global options given to every call
        headers: {
            "Authorization": "Basic " + btoa('Foo' + ":" + 'Bar')
        },
        parse: "json" // All fetch Body methods are supported [arrayBuffer, blob, formData, json, text]
    }
});

// Anywhere you make the API available you can use it to call your specified functions
API.users.save({id: 5, name: 'FooBaR'}).then(function(result){
	// Do something with the result
	// If you passed a valid parse option the result here will already be parsed
	// If not then you can parse it yourself by calling result.json() or any other Body parsing method
}).catch(function(error){
	// Handle API error
});