# constructorio

> Constructor.io API client

Latest version **2.6.1** (published 2019-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install constructorio
pnpm add constructorio
yarn add constructorio
bun add constructorio
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.6.1 |
| Published | 2019-09-02 |
| First published | 2015-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= v0.8.0 |
| Dependencies | 2 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Dan McCormick |
| Maintainers | danmcc, howonlee |

## Links

- npm: https://www.npmjs.com/package/constructorio
- Repository: https://github.com/Constructor-io/constructorio-javascript
- Issues: https://github.com/Constructor-io/constructorio-javascript/issues
- npm.io page: https://npm.io/package/constructorio

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.0
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0

## Recent versions

- 2.6.1 (latest) — 2019-09-02
- 2.6.0 — 2019-08-21
- 2.5.0 — 2019-08-06
- 1.0.3 — 2016-10-17
- 1.0.2 — 2016-04-07
- 1.0.1 — 2015-08-21
- 1.0.0 — 2015-08-21
- 0.0.1 — 2015-07-22

## README

# Constructor-IO JavaScript Client
[Constructor.io](http://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](https://docs.constructor.io/rest-api.html?javascript#introduction).

# Installation

With npm:

```bash
npm install constructorio
```

## Usage

Create a new instance with your API token and API key (available from the [Customer Dashboard](https://constructor.io/dashboard)):

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

To add an item to your index:

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

To remove an item from your index:

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

To modify an item in your index:

```javascript
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:

```javascript
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:

```javascript
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);  
});
```

---
_Source: https://npm.io/package/constructorio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
