https://github.com/decompil3d/servicemeow
A Javascript client for the ServiceNOW REST API.
https://github.com/decompil3d/servicemeow
hacktoberfest
Last synced: 4 months ago
JSON representation
A Javascript client for the ServiceNOW REST API.
- Host: GitHub
- URL: https://github.com/decompil3d/servicemeow
- Owner: decompil3d
- License: apache-2.0
- Created: 2020-10-30T20:45:33.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2026-03-05T19:42:35.000Z (4 months ago)
- Last Synced: 2026-03-05T22:46:07.911Z (4 months ago)
- Topics: hacktoberfest
- Language: JavaScript
- Homepage:
- Size: 155 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
 [](https://coveralls.io/github/decompil3d/servicemeow?branch=main)
# ServiceMeow
A Node.js client for the ServiceNOW REST API.
## Installation
Run `npm install servicemeow` to install the package.
## Basic Usage
```
const ServiceMeow = require('servicemeow');
const sm = new ServiceMeow('https://.service-now.com','','');
const record = await sm.getSingleRecord('', );
```
## Supported Actions
```js
// returns JSON of record
getSingleRecord('', '');
// returns sys_id of created record
createRecord('', { /* */ });
// returns true if success, false otherwise
deleteSingleRecord('', '');
// returns sys_id of updated record
updateSingleRecord('', { /* */ }, '');
// Returns JSON of list of record(s). Use query builder for building advanced serviceNOW encoded query
getRecords('', '');
// returns count of records matching given query
getRecordCount('', '');
```
## Example Usage of Above Actions
```js
const record = await sm.getSingleRecord('', '');
const id = await sm.createRecord('', {'endpoint': 'published'});
const deleted = await sm.deleteSingleRecord('', '');
const id = await servicenowClient.updateSingleRecord('', { /* */ }, '');
// Consider using QueryBuilder to create encoded queries
const records = await servicenowClient.getRecords('', '');
const count = await sm.getRecordCount('', '');
```
## Query Builder Example Usage
```js
const { QueryBuilder } = require('servicemeow');
const queryBuilder = new QueryBuilder();
// Less than '<'
const query = queryBuilder.field('sys_created_on').lessThan('2019-02-15 14:30:18');
// Less than using Date object
const query = queryBuilder.field('sys_created_on').lessThan(new Date());
// Greater than using Date object
const query = queryBuilder.field('sys_created_on').lessThan(new Date());
// compound query using and, lessThan, greaterThan
const query = queryBuilder.field('number').greaterThan('S').and().field('sys_created_on').lessThan(new Date());
// Between two dates, numbers, Strings
const query = queryBuilder.field('sys_created_on').between('2015-02-15 14:30:18', '2019-02-18 14:30:18');
const query = queryBuilder.field('risk_score').between(47, 52);
const query = queryBuilder.field('number').between('A', 'Z');
// Empty String query
const query = queryBuilder.field('description').isEmptyString();
// Example of 'IN' operator
const query = queryBuilder.field('number').isOneOf(['INC0010122','INC0010120']);
// Example of 'NOT IN' operator
const query = queryBuilder.field('foo').isNoneOf(['bar', 'baz']);
// Is anything operator
const query = queryBuilder.field('number').isAnything();
// Contains operator
const query = queryBuilder.field('number').contains('');
// Order ascending/descending
const query = queryBuilder.field('number').contains('').or().contains('').orderAscending();
// Multiple conditions on a single field
const query = queryBuilder.field('number').contains('').and().contains('').orderDescending();
// Ends with operator
const query = queryBuilder.field('number').endsWith('');
// Does not contain
const query = queryBuilder.field('number').doesNotContain('');
// equals
const query = queryBuilder.field('number').equals('/');
// isEmpty
const query = queryBuilder.field('number').isEmpty();
// isNotEmpty
const query = queryBuilder.field('number').isNotEmpty();
// Example of 'SAMEAS' operator
const query = queryBuilder.field('left').isSameAs('middle');
// Example of 'NSAMEAS' operator
const query = queryBuilder.field('left').isNotSameAs('right');
// Example of 'GT_FIELD' operator
const query = queryBuilder.field('foo').greaterThanField('bar');
// Example of 'GT_OR_EQUALS_FIELD' operator
const query = queryBuilder.field('foo').greaterThanOrEqualsField('bar');
// Example of 'LT_FIELD' operator
const query = queryBuilder.field('foo').lessThanField('bar');
// Example of 'LT_OR_EQUALS_FIELD' operator
const query = queryBuilder.field('foo').lessThanOrEqualsField('bar');
// Example of 'RELATIVEGT' operator
const query = queryBuilder.field('sys_updated_on').since(1, 'hour');
// Example of 'RELATIVELT' operator
const query = queryBuilder.field('sys_updated_on').notSince(10, 'minute');
// Example of 'MORETHAN' operator
const query = queryBuilder.field('sys_created_on').isMoreThan(1, 'year').before('sys_updated_on');
// Example of 'LESSTHAN' operator
const query = queryBuilder.field('sys_created_on').isLessThan(12, 'hour').before('sys_updated_on');
```
## Typings
Typings are automatically generated from the JSDoc comments prior to npm publish. As such, declaration files are
included in the npm package distribution but not committed to git.
## Acknowledgements
ServiceMeow was forked from [`ServiceNOW-Client`](https://github.com/Kaushal28/ServiceNOW-Client) by
[Kaushal Shah](https://github.com/Kaushal28).