-1

I've looked in the watson-developer-cloud package and its namesake namespace on GitHub. Will I need to go directly to the REST API in my app?

4

1 回答 1

0

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));
    });
    
于 2015-12-22T14:47:20.390 回答