Licence
—
Version
11.0.0
Deps
5
Size
9 kB
Vulns
0
Weekly
0
n-lists-client
A very thin wrapper around the Content API and n-es-client to search and retrieve content from lists in a simple, DRY manner.
const lists = require('@financial-times/n-lists-client');
lists.get('bc81b5bc-1995-11e5-a130-2e7db721f996').then((data) => { … });
Installation
# install from NPM
$ npm i -S @financial-times/n-lists-client
# add Content API key
export API_KEY=123
# add Elasticsearch read AWS access key
export ES_AWS_ACCESS_KEY=456
# add Elasticsearch read AWS secret access key
export ES_AWS_SECRET_ACCESS_KEY=789
Usage
All methods return a promise. If a request errors then it will be rejected with an appropriate HTTP error.
All methods have an optional options argument that accepts a hash of option properties. Current options are:
fields- an array of fields to fetch from Elasticsearch.
All methods have an optional final timeout argument that defaults to 3 seconds.
.get(listID[, options][, timeout])
Get a list by list ID (which must be a valid UUID.)
Example
lists.get("bc81b5bc-1995-11e5-a130-2e7db721f996", {
fields: ["id", "title"],
});
.for(listType, conceptID[, options][, timeout])
Get a curated list for a concept. Must be a known list type.
lists.for("TopStories", "c91b1fad-1097-468b-be82-9a8ff717d54c", {
fields: ["id", "title"],
});