Ruby SDK v0.4.0

About

This is the Ruby client for AYLIEN News API.

Installation

RubyGems

Add this to the Gemfile:

gem 'aylien_news_api'

or install it directly:

gem install aylien_news_api

Git

Add the following in the Gemfile:

gem 'aylien_news_api', :git => 'https://github.com/AYLIEN/aylien_newsapi_ruby.git'

Getting Started

Please follow the installation instruction and execute the following code:

# Load the gem
require 'aylien_news_api'

# Setup authorization
AylienNewsApi.configure do |config|
  # Configure API key authorization: app_id
  config.api_key['X-AYLIEN-NewsAPI-Application-ID'] = 'YOUR_APP_ID'
  
  # Configure API key authorization: app_key
  config.api_key['X-AYLIEN-NewsAPI-Application-Key'] = 'YOUR_APP_KEY'
end

api_instance = AylienNewsApi::DefaultApi.new

opts = {
  :title => 'trump',
  :published_at_start => "NOW-7DAYS",
  :published_at_end => "NOW",
  :entities_body_links_dbpedia => [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ],
  :language => ['en'],
  :sort_by => 'social_shares_count.facebook'
}


begin
  #List stories
  result = api_instance.list_stories(opts)
  puts result
rescue AylienNewsApi::ApiError => e
  puts "Exception when calling DefaultApi->list_stories: #{e}"
end