【问题标题】:Is there a javascript/Node.js library for accessing the Alchemy Data News API? [closed]是否有用于访问 Alchemy Data News API 的 javascript/Node.js 库? [关闭]
【发布时间】:2016-03-28 19:20:42
【问题描述】:

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

【问题讨论】:

标签: javascript node.js ibm-watson alchemyapi


【解决方案1】:

您可以使用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));
    });
    

【讨论】:

  • 我发誓我在问这个问题之前尝试过,但没有成功。但它现在有效!谢谢@german-attanasio
猜你喜欢
  • 2016-07-08
  • 2011-02-09
  • 1970-01-01
  • 2010-10-12
  • 1970-01-01
  • 2017-06-01
  • 2010-10-11
  • 2011-12-03
  • 1970-01-01
相关资源
最近更新 更多