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 🙏

© 2026 – Pkg Stats / Ryan Hefner

servicenow-api

v1.5.1

Published

Access data from ServiceNow

Readme

ServiceNow API

This is a module that sends http requests to ServiceNow and returns an object with an array of incidents.

Installation

Install the module via npm specifying a version.

npm install servicenow-api --save

Configuration

The object is a function that is expecting config parameters to be passed.

// Modules
// The object passed can be omitted if the properties are set in the configs.

var servicenow = require('servicenow-api')({
	baseurl: 'https://mycompany.service-now.com/api/now/v1',
	auth: {
		user: 'myusername',
		pass: 'mypassword'
	},
	defaults: {
		proxy: 'http://proxy.mycompany.com:8080',
		agent: false
	},
	tableAPI: {
		incidents: 'incident', // label: 'endpoint'
		users: 'sys_user'
	}
});

Usage

After configuration the module will return an object with api endpoints.

var incidents = require('servicenow-api').tableAPI.incidents;

or

var servicenow = require('servicenow-api');
var incidents  = servicenow.tableAPI.incidents;
var users      = servicenow.tableAPI.users;

Methods

.create({object})

return incidents.create({ short_description: 'Create Me!'}).then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

.find({object})

return incidents.find({number:'=INC0034551'}).then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

.find([array])

return incidents.find(['number=INC0034551']).then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

.find('string')

return incidents.find('?sysparm_limit=3&sys_created_on>=javascript:gs.beginningOfThisYear()').then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

.find(sys_id)

return incidents.find('ed9378804f94a6405df4d0af0310c7b8').then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

.update(sys_id, {object})

return incidents.update('ed9378804f94a6405df4d0af0310c7b8', { short_description: 'Fix Me Now!'}).then(function (data)
{
	return data;
}).catch(function (err)
{
	throw err;
});

HTTP Authentication

https://github.com/request/request#http-authentication

request.get('http://some.server.com/').auth('username', 'password', false);
// or
request.get('http://some.server.com/', {
  'auth': {
    'user': 'username',
    'pass': 'password',
    'sendImmediately': false
  }
});
// or
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
// or
request.get('http://some.server.com/', {
  'auth': {
    'bearer': 'bearerToken'
  }
});

If passed as an option, auth should be a hash containing values:

  • user || username
  • pass || password
  • sendImmediately (optional)
  • bearer (optional)

The method form takes parameters auth(username, password, sendImmediately, bearer).

sendImmediately defaults to true, which causes a basic or bearer authentication header to be sent. If sendImmediately is false, then request will retry with a proper authentication header after receiving a 401 response from the server (which must contain a WWW-Authenticate header indicating the required authentication method).

Note that you can also specify basic authentication using the URL itself, as detailed in RFC 1738. Simply pass the user:password before the host with an @ sign:

var username = 'username',
    password = 'password',
    url = 'http://' + username + ':' + password + '@some.server.com';

request({url: url}, function (error, response, body) {
   // Do more stuff with 'body' here
});

Digest authentication is supported, but it only works with sendImmediately set to false; otherwise request will send basic authentication on the initial request, which will probably cause the request to fail.

Bearer authentication is supported, and is activated when the bearer value is available. The value may be either a String or a Function returning a String. Using a function to supply the bearer token is particularly useful if used in conjunction with defaults to allow a single function to supply the last known token at the time of sending a request, or to compute one on the fly.