node-siftscience
v1.1.0
Published
Node HTTP client for Sift Science's API
Downloads
799
Maintainers
Readme
node-siftscience
Node client for Sift Science API
Node JS, Promise Based HTTP Client for Sift Science's API.
Installation
npm install node-siftscience --save
Quick Start
Create a Sift Science HTTP Client using your API Key:
//get the Sift Science factory
const SiftScienceClient = require('node-siftscience');
//create an instance of the Sift Science client
const client = new SiftScienceClient('your API Key');
//now you can use the client to make requests to Sift Science's API
client.events.create({
$type: 'your custom event'
});
Table of Contents
Debug mode
When creating your Sift Science Client instance you can put it in debug mode to log any errors
const client = new SiftScienceClient('your API Key',{
debugMode: true
});
Events
Custom Events
client.events.create({
$type: 'your custom event',
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
The library also supports shortcuts for Sift Science's Reserved Events:
Create Order
client.events.createOrder({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Update Order
client.events.updateOrder({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Transaction
client.events.transaction({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Create Account
client.events.createAccount({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Update Account
client.events.updateAccount({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Update Password
client.events.updatePassword({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Create Content
client.events.createContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Update Content
client.events.updateContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Content Status
client.events.contentStatus({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Flag Content
client.events.flagContent({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Add Promotion
client.events.addPromotion({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Add Item To Cart
client.events.addItemToCart({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Remove Item From Cart
client.events.removeItemFromCart({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Submit Review
client.events.submitReview({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Send Message
client.events.sendMessage({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Login
client.events.login({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Logout
client.events.logout({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Link Session To User
client.events.linkSessionToUser({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Chargeback
client.events.chargeback({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Order Status
client.events.orderStatus({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Verification
client.events.verification({
$user_id : '123',
$session_id: 'gigtleqddo84l8cm15qe4il'
});
Labels
Label User
client.labels.createByUserId('userId', {
$type: 'your custom event',
$is_bad : true,
$abuse_types: 'payment_abuse,promotion_abuse'
});
Unlabel User
client.labels.deleteByUserId('userId', {
$abuse_types: 'payment_abuse,promotion_abuse'
});
Score
User 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
Apply Decisions
User decision
client.decisions.applyByAccountIdAndUserId('accountId', 'userId', {
decision_id : 'user_looks_ok_payment_abuse'
});
Order decision
client.decisions.applyByAccountIdAndOrderId('accountId', 'userId', 'orderId', {
decision_id : 'user_looks_ok_payment_abuse'
});
Session decision
client.decisions.applyByAccountIdAndSessionId('accountId', 'userId', 'sessionId', {
decision_id : 'user_looks_ok_payment_abuse'
});
User Decisions
client.decisions.getByAccountIdAndUserId('accountId', 'userId');
Order Decisions
client.decisions.getByAccountIdAndOrderId('accountId', 'orderId');
Decisions List
client.decisions.listByAccountId('accountId');