是否有用于访问 Alchemy 数据新闻 API 的 javascript/Node.js 库?

Is there a javascript/Node.js library for accessing the Alchemy Data News API?

我在 GitHub 上查看了 watson-developer-cloud 包及其同名命名空间。我是否需要直接转到我的应用程序中的 REST API?

您可以使用 watson-developer-cloud npm 模块访问所有 Watson 和 Alchemy API。

  1. 安装 npm 模块。

    $ npm install watson-developer-cloud
    
  2. Bluemix 获得一把 Alchemy API 钥匙。

  3. 使用以下内容创建一个 test.js 文件

    var watson = require('watson-developer-cloud');
    
    var alchemy_data_news = watson.alchemy_data_news({
      api_key: '<api_key>'
    });
    
    var params = {
      start: 'now-1d',
      end: 'now'
    };
    
    alchemy_data_news.getNews(params, function (err, news) {
      if (err)
        console.log('error:', err);
      else
        console.log(JSON.stringify(news, null, 2));
    });