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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sf-einstein

v0.0.10

Published

Salesforce Einstein API

Readme

Welcome to SF Einstein!

Javascript library for consuming Salesforce Einstein API as per Documentation

Getting Started

Setup

var sfEinstein = require('sf-einstein');

sfEinstein.setup({
    baseUrl :  'https://api.einstein.ai',
    accountId :  <your_account_id>,
    privateKey :  <your_private_key>
});

Get Token - Documentation

Generates a new token based on the details set in the Setup step

sfEinstein.getToken().then((token) => {
    console.log(token);
});

Datasets

Create a Dataset - Documentation

Asynchronously creates a dataset based either on an URL or a .zip file

Create a Dataset from URL

sfEinstein.createDatasetFromUrl('My Dataset', 'image', 'https://www.path.to/my_file.zip')
.then((response) => {
    console.log(response.id);
});

Create a Dataset from .zip file

var fs = require('fs');

var myDatasetFile = fs.createReadStream('/foo/dataset.zip');
sfEinstein.createDatasetFromZipFile('My Dataset', 'image', myDatasetFile)
.then((response) => {
    console.log(response.id);
});

Get all Datasets - Documentation

Retrieves all Datasets created for current account

sfEinstein.getDatasets()
.then((response) => {
    var datasets = response.data;
    datasets.forEach(dataset => console.log(dataset.name));
});

Get a Dataset - Documentation

Retrieves a specific Dataset

sfEinstein.getDataset('123456')
.then((dataset) => {
    console.log(dataset.name);
});

Delete a Dataset - Documentation

Deletes a specific Dataset

sfEinstein.deleteDataset('123456')
.then((deletion) => {
    console.log(deletion.id);
});

Get Deletion Status - Documentation

Retrieves status of a Dataset deletion

sfEinstein.getDatasetDeletionStatus('Z2JTFBF3A7XKIJC5QEJXMO4HSY')
.then((deletion) => {
    console.log(deletion.status);
});

Training

Get Training Status - Documentation

Returns the status of a model's training process

sfEinstein.getTrainingStatus('X6FKINOA2K33JSCN63RO6J3SQM')
.then((training) => {
    console.log(training.status);
});

Train a Dataset - Documentation

Trains a dataset and creates a model

sfEinstein.trainDataset('Name', '123456')
.then((training) => {
    console.log(training.modelId);
});

Retrain a Dataset - Documentation

Retrains a dataset and updates a model

sfEinstein.retrainDataset('7JXCXTRXTMNLJCEF2DR5CJ46QU')
.then((retraining) => {
    console.log(retraining.status);
});

Predictions

Predict by URL - Documentation

Retrieves a prediction from a model for the image on the url passed

sfEinstein.predictByUrl('123456', 'https://www.path.to/image.jpg')
.then((prediction) => {
    prediction.probabilities.forEach((prob) => {
        console.log(prob.label + ' : ' + prob.probability);
    });
});

Predict by Base64 String - Documentation

Retrieves a prediction from a model for the image decoded into Base64 String

sfEinstein.predictByImageBase64('123456', 'data:image/jpeg;base64,/9j/4RiDRXhpZgAATU0AKgA')
.then((prediction) => {
    prediction.probabilities.forEach((prob) => {
        console.log(prob.label + ' : ' + prob.probability);
    });
});

Predict by Image File - Documentation

Retrieves a prediction from a model for the image file

var fs = require('fs');

var myImage = fs.createReadStream('/foo/bar.jpg');
sfEinstein.predictByImageBase64('123456', myImage)
.then((prediction) => {
    prediction.probabilities.forEach((prob) => {
        console.log(prob.label + ' : ' + prob.probability);
    });
});