
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
samanage-api
Advanced tools
This is my personal API library for performing calls to The Samanage Service Platform. The code is provided as-is, without any warrenty. It is a work in progress and may not support all the options offered by the Samanage API Feel free to contact me with requests, issues or questions.
samanage-api code is reviewed with
and unit tested with

npm install samanage-api
You will need a Samanage API token. How to get a token
var SamanageAPI = require('samanage-api')
var connection = new SamanageAPI.Connection("your-token-here")
var success = function({data, ref, pagination_info}) {...}
var failure = function({error, info, httpStatus, ref}) {...}
var request = ... // see below different requests
connection.callSamanageAPI(request).then(success).catch(failure)
The 'ref' attribute in the success and failure callbacks can be set during the call itself, like so:
var my_ref = 'whatever custom information. can also be of any type'
connection.callSamanageAPI(request, my_ref).then(success).catch(failure)
Retries are supported out of the box for certain HTTP codes which are retryable
you can configure the retry logic
var OPTS = { // see 'retry' npm module for full documentation
retries: 3,
factor: 2,
minTimeout: 1 * 100,
maxTimeout: 60 * 100,
randomize: true,
}
// For all requests on a specific connection
connection.retry_opts = OPTS
connection.callSamanageAPI(request, ref).then(...).catch(...)
// For a particular request
request.retry_opts = OPTS
connection.callSamanageAPI(request, ref).then(...).catch(...)
var get_incidents = SamanageAPI.get('incident')
var request = get_incidents(
new SamanageAPI.Filters().add({
sort_order: 'ASC',
sort_by: 'created_at',
created: ['2018-01-01','2018-01-02']
})
)
connection.callSamanageAPI(...)
var get_incidents = SamanageAPI.get('incident')
var filters = new SamanageAPI.Filters().
sort_by('name').
sort_order(SamanageAPI.Filter.DESC).
between_dates('created','2018-01-01','2018-01-02').
per_page(100).
page(3)
var request = get_incidents(filters)
var export_incidents = SamanageAPI.export('incident')
connection.callSamanageAPI(
export_incidents(
new SamanageAPI.Filters().between_dates('created','2017-01-01','2018-07-07')
)
).then(function (result) {
/* Success:
result contains pagination info (how many incidents are there) but
does NOT contain the incidents' data. It is sent via email
*/
}).catch(function(error) {
// Failure
})
var request = SamanageAPI.update('incident')(3, {
name:'opened with samanage-api-js library'
})
var request = SamanageAPI.create('incident')({
name:'opened with samanage-api-js library'
})
SamanageAPI has built in help. Open a new node console, and execute this:
var SamanageAPI = require('samanage-api')
console.log(SamanageAPI.help)
console.log(SamanageAPI.Filters.help)
console.log(SamanageAPI.Connection.help)
Getter objects are promises to get all items of certain type that match a specific SamanageAPI.Filter.
Getters are very convenient way of retrieving things like Itsm States or Users,
but may not be proper strategy for retrieving very large sets of items
(e.g. all audit logs since start of time);
Currently there's no check on number of items which will cause a very long retrieval process so just go ahead and experiment
Getters are defined like this:
// promise to get all ITSM states:
var itsm_states = connection.getter('itsm_state')
// promise to get all users created between certain dates
var users_filter = (new SamanageAPI.Filter()).between_dates('created','2017-01-01','2018-07-07')
var users = connection.getter('user', users_filter)
// promise to get all comments of particular incident
var comments = connection.getter('comment', (new SamanageAPI.Filters()), 'incidents/' + incident.id)
Example: Do something after both users and itsm states are retrieved
Promise.all([itsm_states, users]).then(
function([states, users]) {...}
)
FAQs
Library for performing API calls to Samanage Helpdesk Service
We found that samanage-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.