Get Your API Credentials

If you haven't already done so, you will need to sign up.

Sign up to our free plan here:

The Free plan allows you to make 1,000 calls/day for free. For further information on paid plans please visit our plans page.

Getting Started with AYLIEN Text Analysis API Using Ruby


  • Ruby (>= 1.9)

Getting the SDK

The easiest way to get the Ruby SDK is to use RubyGems.

$ gem install aylien_text_api

Using the SDK

The following example demonstrates how to calculate the sentiment of a simple sentence, and determine the language it's written in.

require "aylien_text_api"

AylienTextApi.configure do |config|
  config.app_id  = "YourApplicationId"
  config.app_key = "YourApplicationKey"
client =

# or pass them as parameters to AylienTextApi::Client class.
# client = "YourApplicationId", app_key: "YourApplicationKey")

text = "John is a very good football player!"

# returns nil in case of errors
sentiment = client.sentiment text: text

# returns an exception in case of errors
language = client.language! text: text

puts "Sentiment: #{sentiment[:polarity]} (#{sentiment[:polarity_confidence]})"
puts "Language: #{language[:lang]} (#{language[:confidence]})"