Giter VIP home page Giter VIP logo

node-siftscience's Introduction

node-siftscience

Node client for Sift Science API

Build Status

Coverage Status

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

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

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

node-siftscience's People

Contributors

officert avatar grantgasp avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.