Skip to content

Instantly share code, notes, and snippets.

@stevensona
Last active March 6, 2016 21:07
Show Gist options
  • Save stevensona/0c7ddfbb37bdb6d4cafe to your computer and use it in GitHub Desktop.
Save stevensona/0c7ddfbb37bdb6d4cafe to your computer and use it in GitHub Desktop.
Use IBM Watson AlchemyAPI to display the sentiment of us stock market news
require 'httparty'
key = @apikey
target = 'http://feeds.reuters.com/news/usmarkets?format=html'
url = "http://gateway-a.watsonplatform.net/calls/url/URLGetTextSentiment?apikey=#{key}&url=#{target}&outputMode=json"
response = HTTParty.post(url, headers: {'Content-Type' => 'application/x-www-form-urlencoded'})
puts response.body
@stevensona
Copy link
Author

{ "status": "OK", "usage": "By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html", "url": "http://feeds.reuters.com/news/usmarkets?format=html", "totalTransactions": "1", "language": "english", "docSentiment": { "mixed": "1", "score": "-0.198827", "type": "negative" } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment