Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Node client for Sift Science API

License

Notifications You must be signed in to change notification settings

Truebill/node-sift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-sift

Node client for Sift API

Build Status

Coverage Status

Node JS, Promise Based HTTP Client for Sift's API.

Installation

npm install node-sift --save

Quick Start

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'
});

Table of Contents

Debug mode

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
});

Events

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'
});

Labels

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'
});

Score

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'
});

Decisions

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');

Packages

No packages published

Languages

  • JavaScript 99.5%
  • Makefile 0.5%