Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
141 lines (88 sloc) 5.7 KB


Search the Internet (or parts of the Internet!) with ease. This gem is powered by

This gem is based on work done on during RailsRumble 2012.


Add this line to your application's Gemfile:

gem 'blekko-search'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install blekko-search


Use this gem for quick searches or to manage groups of slashtags and more complicated search goals.


While blekko asks that you request an API key, you don't need one to start.

blekko =

While blekko is known for their slashtag based searching, you can search without one:

results ="chicago")

The search method returns an array of SearchResult instances that expose all blekko attributes (and a few more).

If you want to search using blekko slashtags, include a :slashtags argument in your search.

results ="chicago", slashtags: "/sports")

Blekko allows for a maximum of 100 results per search, but if you'd like more, you can set the :total_size argument.

results ="something funny", total_size: 1000)

By default, the searches will be made 100 results at a time, but you can reduce the page size using the :page_size argument too.

Blekko asks that users of its API limit searches to one per second. This gem doesn't include that, but you may want to implement that feature (or send a pull request) especially if you are multithreading the search.


Each result includes the attributes that blekko provides, plus a couple more:

  • n_group (alias: sequence) = The number of the search result in the overall results from blekko.
  • url = The url of the result.
  • display_url = A url formatted for display.
  • rss = The rss of the result, if available.
  • rss_title = The title of the rss of the result, if available.
  • short_host_url = The url of the host of the result.
  • short_host = The url of the host formatted for display.
  • snippet (alias: abstract) = A description of the result formatted for display including html
  • toplevel = Is the result a top level domain?
  • url_title = The title of the url formatted for display including html
  • date = The date of the the result's document, if available. Parsed from doc_date_iso.
  • address = The address of the result, if available (not too often).
  • geocluster = The geocluster of the result, if avaiable.
  • lat = The lat of the result, if available.
  • lon = The lon of the result, if available.
  • phone = The phone number of the result, if available.
  • zip = The zip of the result, if available.
  • is_robots_banned = Does this result ban robots? Almost never available.


From "What is a slashtag?" on

A slashtag is an easy-to-create custom search engine. It is a tool used to filter search results and helps you to search only high quality sites, without spam or content farms. Slashtags contain a list of websites and when you search with a slashtag, you only search those sites. Some slashtags perform functions such as ordering the results by date.


You can view the urls for any slashtag that is public, or for any private slashtag that you have access to if you are logged in.

slashtag = blekko.slashtag("/sports")

By default, the slashtag will load the urls from blekko if the slashtag exists.

urls = blekko.slashtag("/sports").urls

Prevent the slashtag from loading its urls automatically by setting the :eager_load argument to false.

slashtag = blekko.slashtag("/sports", eager_load: false)

Access the urls currently saved on at any point:


Create & Edit

To create or edit a slashtag you'll need to use a blekko instance that has logged in using it's username and password.

blekko = "derekrose", password: "comeback", api_key: "1")

You will be logged in automatically if you provide all three credentials when you create the Blekko instance. Otherwise, you can call the login method to authenticate.

blekko =
blekko.username = "derekrose"
blekko.password = "comeback"
blekko.api_key = "1"

Create a slashtag using the same syntax as used for the view method. You can pass in the urls when you initialize a new instance.

slashtag = blekko.slashtag("/my/sports", urls: ["", "http://"])

You can add urls to an existing slashtag object.

slashtag = blekko.slashtag("/my/sports")
slashtag.urls << ""

To save the slashtags to blekko call save!. This will either create a new slashtag or update the existing slashtag.!

Remove URLS

You can also remove URLs from a slashtag.

slashtag = blekko.slashtag("/my/sports")


The API does not currently support deleting slashtags. You'll need to login to to delete a slashtag from your account.


Thanks to for providing API access to their search engine.

<3 @barelyknown


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
  6. Thank you :)
Jump to Line
Something went wrong with that request. Please try again.