2.6.1 • Published 5 years ago

constructorio v2.6.1

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

Constructor-IO JavaScript Client

Constructor.io provides search as a service that optimizes results using artificial intelligence (including natural language processing, re-ranking to optimize for conversions, and user personalization).

Documentation

For the most up-to-date documentation for this library, please visit our API Documentation.

Installation

With npm:

npm install constructorio

Usage

Create a new instance with your API token and API key (available from the Customer Dashboard):

var ConstructorIO = require('constructorio');
var constructorio = new ConstructorIO({
  apiToken: "your API token", 
  apiKey: "your API key",
});

To add an item to your index:

constructorio.addItem({
  item_name: "power_drill",
  section: "Products"
}, function(error, response) {
    console.log(response);
});

To remove an item from your index:

constructorio.removeItem({
  item_name: "power_drill",
  section: "Products"
}, function(error, response) {
    console.log(response);  
});

To modify an item in your index:

constructorio.modifyItem({
  item_name: "power_drill",
  section: "Products",
  url: "http://www.mysite.com/power_drill",
}, function(error, response) {
  console.log(response);
});

To get autocomplete results:

const userParams = {
  i: 'user device identifier',
  s: 1
};

constructorio.getAutocompleteResults({
  query: 'powe',
  num_results: 4,
}, userParams, function(error, response) {
  console.log(response);  
});

To get search results:

const userParams = {
  i: 'user device identifier',
  s: 1
};

constructorio.getSearchResults({
  query: 'power drill',
  section: 'Products',
  sort_by: 'relevance',
}, userParams, function(error, response) {
  console.log(response);  
});
2.6.1

5 years ago

2.6.0

5 years ago

2.5.0

5 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.1

9 years ago