Node client for Sift API
Node JS, Promise Based HTTP Client for Sift's API.
npm install node-sift --save
Create a Sift HTTP Client using your API Key:
//get the Sift factory
const SiftClient = require('node-sift');
//create an instance of the Sift client
const client = new SiftClient('your API Key');
//now you can use the client to make requests to Sift's API
client.events.create({
$type: 'your custom event'
});
When creating your Sift Client instance you can put it in debug mode to log any errors
const client = new SiftClient('your API Key',{
debugMode: true
});
client.events.create({
$type: 'your custom event',
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
The library also supports shortcuts for Sift's Reserved Events:
client.events.createOrder({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.updateOrder({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.transaction({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.createAccount({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.updateAccount({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.createContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.updateContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.contentStatus({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.flagContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.addPromotion({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.addItemToCart({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.removeItemFromCart({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.submitReview({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.sendMessage({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.login({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.logout({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.linkSessionToUser({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.chargeback({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.orderStatus({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.events.verification({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
client.labels.createByUserId('userId', {
$type: 'your custom event',
$is_bad : true,
$abuse_types: 'payment_abuse,promotion_abuse'
});
client.labels.deleteByUserId('userId', {
$abuse_types: 'payment_abuse,promotion_abuse'
});
client.score.getByUserId('userId', {
$abuse_types: 'payment_abuse,promotion_abuse'
});
You can also ask the API to return a user's score when creating events.
client.events.create({
$type: 'your custom event',
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
}, { //2nd argument are query string params
$return_score: true,
$abuse_types: 'payment_abuse,promotion_abuse'
});
client.decisions.applyByAccountIdAndUserId('accountId', 'userId', {
decision_id : 'user_looks_ok_payment_abuse'
});
client.decisions.getByAccountIdAndUserId('accountId', 'userId');
client.decisions.getByAccountIdAndOrderId('accountId', 'orderId');
client.decisions.listByAccountId('accountId');