tearex
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

TeaRex AI NodeJS SDK

This package provides a NodeJS SDK for the tearex.ai Recommendation Engine API. If you don't have a tearex.ai account, you can request one here: tearex.ai.

Documentation

For more information about the API, please refer to the documentation.

Installation

To install the SDK, run the following command:

npm install --save tearex

Usage

Import the SDK:

const trx = require('tearex');

Initialize the SDK

Provide the url of the API and your API KE as an environment variable TEAREX_URL and TEAREX_API_KEY, or pass them as an argument to the init function:

trx.init({uri: 'YOUR_TEAREX_API_URL', apiKey: 'YOUR_TEAREX_API_KEY'});

Example

import trx from 'tearex';

// Initialize the tearex
trx.init()

const alice = {id: 'user-1', label: 'User', properties: {name: 'Alice'}}
const kale = {id: 'product-2', label: 'Product', properties: {name: 'Kale'}}

// Create Alice since she is a new user
(async () => {
    await trx.createEntity(alice)
    
    // Alice purchases Kale, so we create the "Purchased" event
    await trx.createEvent(alice, "Purchased", kale)
    
    // Recommend Alice the next "Product" to purchase
    await trx.recommend(alice, "Product")
})()

Dependents (0)

Package Sidebar

Install

npm i tearex

Weekly Downloads

8

Version

0.1.9

License

ISC

Unpacked Size

1.61 MB

Total Files

14

Last publish

Collaborators

  • ppierzc