Class WbGetEntitiesAction

java.lang.Object
org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction

public class WbGetEntitiesAction extends Object
Java implementation of the wbgetentities action.
Author:
Michael Guenther
  • Constructor Details

    • WbGetEntitiesAction

      public WbGetEntitiesAction(ApiConnection connection, String siteIri)
      Creates an object to fetch data from the given ApiConnection. The site URI is necessary since it is not contained in the data retrieved from the API.
      Parameters:
      connection - ApiConnection Object to send the requests
      siteIri - the URI identifying the site that is accessed (usually the prefix of entity URIs), e.g., "http://www.wikidata.org/entity/"
  • Method Details

    • wbGetEntities

      Creates a map of identifiers or page titles to documents retrieved via the API URL
      Parameters:
      properties - parameter setting for wbgetentities
      Returns:
      map of document identifiers or titles to documents retrieved via the API URL
      Throws:
      MediaWikiApiErrorException - if the API returns an error
      IOException - if we encounter network issues or HTTP 500 errors from Wikibase
      MalformedResponseException - if one of the returned entities cannot be parsed
    • wbGetEntities

      public Map<String,EntityDocument> wbGetEntities(String ids, String sites, String titles, String props, String languages, String sitefilter) throws MediaWikiApiErrorException, IOException
      Creates a map of identifiers or page titles to documents retrieved via the API. All parameters that accept lists expect the pipe character | to be used as a separator, as created by ApiConnection.implodeObjects(Iterable). There is a limit on how many entities can be retrieved in one request, usually 50 by default and 500 for bots. This limit may also apply to the number of language codes and sites used for filtering.

      If an error occurs (e.g., exceptions trying to access the Web API), the exception will be propagated to the caller.

      Parameters:
      ids - list of ids of entities for which data should be retrieved
      sites - site key (e.g. "enwiki"); used together with parameters "titles"; the API supports the use of many site keys with a single title, but this implementation does not support this (the resulting map will use title strings for keys)
      titles - list of titles of the page corresponding to the requested entities on the given site; use together with 'sites', but only give one site for several titles or several sites for one title
      props - list of strings that specifies what kind of data should be retrieved for each entity; possible values include "info", "sitelinks", "sitelinks/urls", "aliases", "labels", "descriptions", "claims" (statements), "datatype"; additional filters may apply; defaults to "info|sitelinks|aliases|labels|descriptions|claims|datatype"
      languages - list of language codes to return labels, aliases or descriptions for; if omitted, data for all languages is returned
      sitefilter - list of site keys to return sitelinks for; if omitted, data for all languages is returned
      Returns:
      map of document identifiers or titles to documents retrieved via the API URL
      Throws:
      MediaWikiApiErrorException - if the API returns an error
      IOException - if we encounter network errors, or HTTP 500 errors on Wikibase's side
      IllegalArgumentException - if the given combination of parameters does not make sense
      MalformedResponseException - if one of the returned entities cannot be parsed