Node client for Sift Science API
Node JS, Promise Based HTTP Client for Sift Science's API.
npm install node-siftscience --save
Create a Sift Science HTTP Client using your API Key:
//get the Sift Science factory
const siftScience = require('node-siftscience');
//create an instance of the Sift Science client
const client = siftScience.init('your API Key');
//now you can use the client to make requests to Sift Science's API
client.events.create({
$type: 'your custom event'
});
When creating your Sift Science Client instance you can put it in debug mode to log any errors
const client = siftScience.init('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 Science'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');