Registry / devops / servicenow-rest-api

servicenow-rest-api

JSON →
library1.2.2jsnpmunverified

Node.js wrapper library for ServiceNow REST API, version 1.2.2. Provides authentication and CRUD operations on ServiceNow tables, including fetching table data, creating/updating/deleting tasks, retrieving attachments, and change tasks. Built on axios, it supports custom proxy settings via https-proxy-agent. Released under MIT, this library aims to simplify integration with ServiceNow but is community-maintained with limited updates, last updated in v1.2.2 (2021). Alternative to official ServiceNow SDK or manual HTTP requests.

npm install servicenow-rest-api
INSTALL
IMPORT
SIG · SERVICENOW-REST-AP
S
servicenow-rest-api
devopsjavascriptv1.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const sn = require('servicenow-rest-api');
import sn from 'servicenow-rest-api';
Library uses CommonJS, not ESM. Default export is a class.
ServiceNow
import { ServiceNow } from 'servicenow-rest-api';
import sn from 'servicenow-rest-api';
Named export available in TypeScript definitions if added, but the package does not ship types. Default export is the class.
sn
const sn = require('servicenow-rest-api'); const ServiceNow = new sn('instance','user','pass');
const { default: ServiceNow } = require('servicenow-rest-api');
Default import is the constructor. Do not destructure default.

Demonstrates basic usage: importing the library, creating an instance with instance name, username, and password from env var, authenticating, and fetching sample data from the 'incident' table.

const sn = require('servicenow-rest-api'); const ServiceNow = new sn('dev12345', 'admin', process.env.SN_PASSWORD ?? ''); ServiceNow.Authenticate(); ServiceNow.getSampleData('incident', (res) => { console.log(res); });
Debug
Known issues
deprecatedThe Authenticate() method may not be required in newer ServiceNow versions or may use deprecated auth endpoints.
fix
Check ServiceNow documentation: modern instances use OAuth or basic auth by default. Consider switching to official SDK.
affects: >=1.0.0
gotchaAll callbacks use a single parameter (response object). They are not Promises; do not await them.
fix
Use callbacks via .then() is not supported. Wrap in a Promise if needed.
affects: >=1.0.0
breakingv1.2.0 changed the response format for getTableData. The array is now nested under 'result' property.
fix
Access data via response.result instead of response directly.
affects: >=1.2.0
gotchaPassword passed in plain text to constructor. Risk of exposure in logs or memory dumps.
fix
Use environment variables and avoid logging credentials. Consider OAuth instead.
affects: >=1.0.0
Errors
Common errors & fixes
ServiceNow.Authenticate is not a function
The import is wrong; likely using ESM import instead of require().
fix
Use CommonJS require: const sn = require('servicenow-rest-api');
TypeError: sn is not a constructor
Attempting to use new sn() after destructuring incorrectly.
fix
Correct: const ServiceNow = new sn('instance','user','pass');
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
axiosrequiredHTTP client for API requests
https-proxy-agentoptionalProxy support for network requests, required if using custom proxy
Agent activity
6 hits · last 30 days
node
6
Resources
servicenow-rest-api — npm install servicenow-rest-api · libregistry