Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Wikidata API changed wbgetitems to wbgetentities

  • Loading branch information...
commit c247da1454736d40361e2e21684d44dfd6ea90c4 1 parent a6c3b28
@njh authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/wikidata_api.rb
View
18 lib/wikidata_api.rb
@@ -7,39 +7,39 @@ def self.api_uri
end
def self.get_sitelink(id, site='enwiki')
- data = self.get('wbgetitems', {
+ data = self.get('wbgetentities', {
:ids => id,
:sites => site,
:props => 'sitelinks',
:languages => 'en'
})
- if data['items'].nil?
+ if data['entities'].nil?
raise MediaWiki::Exception.new('Empty response')
- elsif data['items'][id].nil?
+ elsif data['entities'][id].nil?
raise MediaWiki::NotFound.new('Wikidata identifier does not exist')
- elsif data['items'][id]['sitelinks'][site].nil?
+ elsif data['entities'][id]['sitelinks'][site].nil?
raise MediaWiki::NotFound.new('Sitelink does not exist for Wikidata identifier')
else
- return data['items'][id]['sitelinks'][site]
+ return data['entities'][id]['sitelinks'][site]
end
end
def self.find_by_title(title, site='enwiki')
- data = self.get('wbgetitems', {
+ data = self.get('wbgetentities', {
:titles => title,
:sites => site,
:props => 'info|aliases|labels|descriptions',
:languages => 'en'
})
- if data['items'].nil?
+ if data['entities'].nil?
raise MediaWikiApi::Exception.new('Empty response')
- elsif data['items'].empty? or data['items'].keys.first == "-1"
+ elsif data['entities'].empty? or data['entities'].keys.first == "-1"
raise MediaWikiApi::NotFound.new('Failed to lookup title in Wikidata')
end
- data['items'].values.first
+ data['entities'].values.first
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.