Overview

The first client is written in Node.js. The repository is here: https://github.com/itemsapi/itemsapi-node

Items

This is the most useful and important endpoint.

var facets = {
  tags:['drama', 'war']
};

client.search({
  sort: 'most_votes',
  query: '',
  page: 1,
  aggs: JSON.stringify(facets),
  per_page: 12
}).then(function(res) {
  console.log((res));
})

Example response:

{
  "meta": {
    "query": "",
    "sort": "default",
    "search_time": 15
  },
  "pagination": {
    "page": 1,
    "per_page": 12,
    "total": 3000
  },
  "data": {
    "items": [
      {
        "id": 1173,
        "score": 1,
        "text": "Don't cry because it's over, smile because it happened.",
        "image": "https://d.gr-assets.com/authors/1193930952p2/61105.jpg",
        "author": "Dr. Seuss",
        "book": "",
        "tags": [
          "attributed-no-source",
          "cry",
          "crying",
          "experience",
          "happiness",
          "joy",
          "life",
          "optimism",
          "sadness",
          "smile",
          "smiling"
        ],
        "likes": 147550
      },
      {
        "id": 66,
        "score": 1,
        "text": "So many books, so little time.",
        "image": "https://d.gr-assets.com/authors/1315160559p2/22302.jpg",
        "author": "Frank Zappa",
        "book": "",
        "tags": [
          "books",
          "humor"
        ],
        "likes": 89430
      }
    ],
    "aggregations": {
      "tags_terms": {
        "doc_count": 3000,
        "doc_count_error_upper_bound": 20,
        "sum_other_doc_count": 5335,
        "buckets": [
          {
            "key": "love",
            "doc_count": 332
          },
          {
            "key": "humor",
            "doc_count": 272
          },
          {
            "key": "inspirational",
            "doc_count": 262
          }
        ],
        "title": "tags_terms",
        "name": "tags_terms",
        "type": "terms"
      },
      "authors_terms": {
        "doc_count": 3000,
        "doc_count_error_upper_bound": 13,
        "sum_other_doc_count": 2355,
        "buckets": [
          {
            "key": "Cassandra Clare",
            "doc_count": 118
          },
          {
            "key": "J.K. Rowling",
            "doc_count": 94
          },
          {
            "key": "John Green",
            "doc_count": 94
          },
          {
            "key": "Oscar Wilde",
            "doc_count": 63
          }
        ],
        "title": "authors_terms",
        "name": "authors_terms",
        "type": "terms"
      }
    },
    "sortings": {}
  }
}

Get

client.getItem(id)
.then(function(item) {
  console.log(item);
})

client.getItemByKeyValue('permalink', permalink)
.then(function(item) {
  console.log(item);
})

Response:

{
  "id": 36554,
  "text": "The secret to getting ahead is getting started.",
  "image": "https://d.gr-assets.com/authors/1322103868p2/1244.jpg",
  "author": "Mark Twain",
  "book": "",
  "tags": [
    "starting",
    "working"
  ],
  "likes": 1852
}

Create

Delete

Collections

Aggregations

Mappings

Projects

Was this page helpful ?