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 🙏

© 2025 – Pkg Stats / Ryan Hefner

crystal-sdk

v0.11.0

Published

SDK for Crystal API

Readme

Crystal Javascript SDK

CircleCI branch codecov.io

The Crystal SDK is a library that facilitates communication with the Crystal API. This allows for applications to tailor the experience to fit the personalities of individual users. It also allows for applications to create personality-aware features themselves specifically useful to their problem domain.

Enterprise Access

Contact us at [email protected] to get an Organization Token to utilize this library in your web application.

Installation

Currently, we have two options for installation of the SDK. NPM can be used (preferred) or it can be embedded directly into the page through the Browserify CDN

npm install --save crystal-sdk

If downloaded through NPM, a handle to the SDK can be created:

// Javascript
var CrystalSDK = require('crystal-sdk');

// ECMAScript 6
import CrystalSDK from 'crystal-sdk'

Any of these methods for importing will add CrystalSDK as a variable you can reference.

Authentication

Call this on every page before you make use of the Crystal SDK. This establishes your credentials and enables the rest of the SDK functionality.

CrystalSDK.Authentication.asOrganization("YOUR_ORG_NAME", "YOUR_ORG_TOKEN");

Email Recommendations

The Crystal SDK can be used to make email recommendations to your users. This SDK sends the sender, recipient and the email body to our API for analysis. The sender and recipient are described through Person Search objects. These objects allow for your application to enter whatever it knows about the sender and recipient, giving our API a way to attach them to an identity.

var sender = new CrystalSDK.Person.Search();
sender.first_name = "Cory";
sender.last_name = "Finger";
sender.email = "[email protected]";

var recipient = new CrystalSDK.Person.Search();
recipient.first_name = "Drew";
recipient.last_name = "D'Agostino";
recipient.email = "[email protected]";

An Email Session represents a single email being sent by your user. Your application can make multiple getRecommendation calls from this Email Session without it counting as extra towards your overall limit.

var email_session = new CrystalSDK.Email.Session(sender, recipient);
var email_body = "We'll try to get to that as soon as possible!";

email_session.getRecommendations(email_body).then(function(recommendations) {

 recommendations.forEach(function(rec) {
  console.log("Recommendation for email body starts at character", rec.start);
  console.log("Recommendation for email body ends at character", rec.end);
  console.log("Description of recommendation:", rec.description);
 })

}).catch(function() {
 console.log("Trouble communicating with the API");
});

Let's see the output of that:

Recommendation for email body starts at character 0
Recommendation for email body ends at character 12
Description of recommendation: When you say <b class="red">We'll try to</b>, it can make Drew uncomfortable with ambiguity...

Putting it all together

Here's a fully-formed code sample for using the Crystal SDK on a webpage

<script type="text/javascript" src="https://www.brcdn.org/crystal-sdk/0.*.*?standalone=CrystalSDK&uglify=true"></script>

<script type="text/javascript">
 CrystalSDK.Authentication.asOrganization("YOUR_ORG_NAME", "YOUR_ORG_TOKEN");

 var sender = new CrystalSDK.Person.Search();
 sender.first_name = "Cory";
 sender.last_name = "Finger";
 sender.email = "[email protected]";

 var recipient = new CrystalSDK.Person.Search();
 recipient.first_name = "Drew";
 recipient.last_name = "D'Agostino";
 recipient.email = "[email protected]";

 var email_session = new CrystalSDK.Email.Session(sender, recipient);
 var email_body = "We'll try to get to that as soon as possible!";

 email_session.getRecommendations(email_body).then(function(recommendations) {

  recommendations.forEach(function(rec) {
   console.log("Recommendation for email body starts at character", rec.start);
   console.log("Recommendation for email body ends at character", rec.end);
   console.log("Description of recommendation:", rec.description);
  })

 }).catch(function() {
  console.log("Trouble communicating with the API");
 });
</script>

Contact us if you have any SDK suggestions or need clarification on anything!