Skip to content
Ruby client for "Zemanta - blog publishing assistant"
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Ruby client for Zemanta

This Gem provides Ruby client and comand-line tool for Zemanta API.


To use this client you must gain API key. You can get API key on


Add this line to your Gemfile

gem 'zemanta'

Or install it as seperate gem

$ gem install zemanta

Using Zemanta from comand-line

After installing the Gem create file ~/.zemanta with API key.


For comand-line usage use command -h. You will get following output...

Usage: zemanta COMMAND [options]

    suggest: Suggest method allows to query Zemanta for contextual metadata about a given text.
    -h, --help                       help
    -a, --api_key NEW_KEY            Zemanta api_key
    -t, --text TEXT                  Text to work on
    -f, --file FILE                  File to work on
    -m, --mtype TYPE                 Output type (JSON or RB)
    -r, --result_field FIELD         Result field

Usage example would be...

zemanta suggest -f test_file.txt -r articles -m json

Using Zemanta in your Ruby application

You can use client from your Ruby code or from comand-line.


Zemanta API requires API key, so to use this client you also have to set the key. You can do this like so...

zemanta = "API_KEY_GOES_HERE"

Or if you like class wide key...

Zemanta.api_key = "API_KEY_GOES_HERE"

The 3rd option is to set enviroment variable "ZEMANTA_KEY" and client will pick it up.

Suggests with #suggest method

Zemanta API provides 3 methods; and so does this client. You can use suggest method like so...

suggests ="My long text goes here...")

suggests['articles']    # All the suggested articles
suggests['images']      # All suggested images

For more information and structure look at this #suggest resource.

Suggests with #suggest_markup

In comparison to #zemanta_suggest, this method returns only links to semantical entities.

suggests ="My long text goes here...")

For more information about this response see suggest_markup method documentation.

#preferences method

Method #preferences allows Zemanta API users to get preferences of specific user.

me =
me['user']  # Get nice key...

Client options

Zemanta API methods also provide some additional options. You can use them like so:

suggests = z.suggest("
    Some text here...
    return_images: 0,   # Don't return any images.
    articles_limit: 2   # Limit of articles returned

For more options please read:


Your daily limit is set at 1.000 calls per day. Send email to to make it 10.000 calls per day.

Testing and developement

Client is tested/build with RSpec with help of Guard, but it does NOT use mockups or anything like that. For testing and developement you must get your own Zemanta API Key.


This is unofficial client and comes without any warranty. Please read and use documentation provided by Zemanta.

Contribution and authors

Oto Brglez / @otobrglez /

Something went wrong with that request. Please try again.