ItemsAPI Javascript
Javascript client for ItemsAPI 2.0
Installation
npm install itemsapi
Run ItemsAPI
There are many easy ways to run ItemsAPI 2.0 server.
The simplest one is by using Docker:
docker run --privileged -it -p 3000:3000 itemsapi/itemsapi:latest
Getting started
Here is a quickstart for a search request
const ItemsAPI = require('itemsapi')
(async () => {
const client = new ItemsAPI({
host: 'http://127.0.0.1:3000'
})
const index = client.getIndex();
let response = await index.updateConfig(config);
response = await index.addItems(items);
response = await index.search({
per_page: 3,
filters: {
tags: ['epic']
},
facets_fields: ['tags']
});
console.log(response);
})();
API Resources
Search
await index.search(input)
- List filters for specific facet:
await index.facet(input)
Index
client.getIndex()
Items
await index.addItems(items)
await index.getItem(id)
await index.partialUpdateItem(id, data)
await index.updateItem(id, data)
await index.deleteItem(id)
Configuration
await index.getConfig()
await index.updateConfig(config)