npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sift

v0.0.2

Published

Node HTTP client for Sift Science's API

Downloads

233

Readme

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

Custom Events

client.events.create({
  $type: 'your custom event',
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

The library also supports shortcuts for Sift'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'
});

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

client.decisions.applyByAccountIdAndUserId('accountId', 'userId', {
  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');