node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »


FT API Node Client

This is a node module that acts as a wrapper for the FT content api (


npm install{the version you need}.tar.gz
var client = require('ft-api-client')(apiKey, config);

Where `config is an optional object accepting two properties

  • timeout - maximum time (in ms) to wait for requests to complete
  • errorHandler - function used to handle any errors resulting from any single api call (including the construction of models). The default handler logs to the console when export DEBUG=ft-api-client:*; is set.
  • elasticSearchUri - The URI for the search instance to be used. Along the lines of
  • pollForPages [Boolean]- polls capi periodically for a list of pages. defaults to true



  .then(function (article) {
  }, function (err) {

Or you can get several resources in a single request,

  .then(function (articles) {

Alternatively use the new mget method in exactly the same way. To use mget you need to pass a elasticSearchUri property and value into the configuration


Or retrieve a collection of articles via a search term,

  .search("Climate change")
  .then(function (articles) {

To request more results than the default (5) pass in a second parameter with the number required.


.get() and .search() also accepts an optional second parameter, opts with the following properties

  • strict - By default if a sub-promise of a request for multiple articles is rejected it will, after it is handled by config.errorHandler, be forced to resolve with undefined. This means e.g. Promise.all(client.get(ids, {alwaysResolve: true})) can reliably be used when the success of every call is not essential. If strict: true, then the prmoise will stay in its rejected state.
  • quantity (only applies to search) - max number of results to return (default 5)
  • resultContext (only applies to search) - Overrides the default resultContext config sent to the search api. Each property in this object will override the default. For properties which are arrays, prefixing the property name with '+' will concatenate with the default set e.g. '+aspects': ['example'] will add 'example' to the default list of aspects.


To retrieve the articles in a given page simply search for 'page:page name'. To retrieve metadata about the page use: client .pageInfo("page:page name") .then(function (metadata) { console.log(metadata); })


The capi1 article model is available at require('ft-api-client').models.v1.Article and can be instantiated as follows: new Article({response from capi})


Install the dependencies,

npm install

Check everything works,

make test

Roll up your sleeves and dive in. New features will not be accepted without accompanying tests.