Ruby gem to help with bulk lookups of Wikidata items (currently for internal EveryPolitician use)
Ruby Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin Update files with what bundler 1.10 generates Nov 5, 2015
test Move pry require into test_helper.rb Sep 30, 2016
.rubocop_todo.yml regenerate Rubocop TODO list Sep 22, 2016
Gemfile 0.0.1 Oct 17, 2015
LICENSE.txt 0.0.1 Oct 17, 2015
Rakefile Add Rubocop rake task Sep 22, 2016

Wikisnakker Build Status

This project allows you to do bulk lookups of Wikidata items. If you want to look up large amounts of Wikidata items at once then this library should make that job considerably faster.

⚠️ This project is under heavy development and is in a very pre-alpha state, it's not yet ready for use in production.


  • Many


Add this line to your application's Gemfile:

gem 'wikisnakker', git: ''

And then execute:

$ bundle


You can pass an array of qualifiers to Wikisnakker::Item.find. This will return an array of Wikisnakker::Item instances.

require 'wikisnakker'
items = Wikisnakker::Item.find(['Q2', 'Q513', 'Q41225']) { |item| item.label('en') } # => ["Earth", "Mount Everest", "Big Ben"] { |item| item.P18.value } # => ["", "", ""]

If you pass a string to Wikisnakker::Item.find then it will return a single Wikisnakker::Item instance:

require 'wikisnakker'
douglas_adams = Wikisnakker::Item.find('Q42')
douglas_adams.label('en') # => "Douglas Adams"

Then you can lookup properties on returned items. For example P19 is "place of birth". A P19 is an item, so you can then call .label() on its return value and call further P* methods on it.

cambridge = douglas_adams.P19.value
cambridge.label('en') # => "Cambridge"

P569 is "date of birth" and P570 is "date of death".

douglas_adams.P569.value # => "1952-03-11"
douglas_adams.P570.value # => "2001-05-11"

Sometimes a property will have multiple values, for example P735, which is "given names". In this case you can call P735s on the Wikisnakker::Item instance to get an array back: { |given_name| given_name.value.label('en') }
# => ["Douglas", "Noel"]

You can also lookup aliases in a certain language for an item:

# => ["Douglas Noël Adams", "Douglas Noel Adams"]


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at