Package org.wikidata.wdtk.wikibaseapi
Class WbGetEntitiesAction
java.lang.Object
org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction
Java implementation of the wbgetentities action.
- Author:
- Michael Guenther
-
Constructor Summary
ConstructorDescriptionWbGetEntitiesAction
(ApiConnection connection, String siteIri) Creates an object to fetch data from the given ApiConnection. -
Method Summary
Modifier and TypeMethodDescriptionwbGetEntities
(String ids, String sites, String titles, String props, String languages, String sitefilter) Creates a map of identifiers or page titles to documents retrieved via the API.wbGetEntities
(WbGetEntitiesActionData properties) Creates a map of identifiers or page titles to documents retrieved via the API URL
-
Constructor Details
-
WbGetEntitiesAction
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 requestssiteIri
- the URI identifying the site that is accessed (usually the prefix of entity URIs), e.g., "http://www.wikidata.org/entity/"
-
-
Method Details
-
wbGetEntities
public Map<String,EntityDocument> wbGetEntities(WbGetEntitiesActionData properties) throws MediaWikiApiErrorException, IOException 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 errorIOException
- if we encounter network issues or HTTP 500 errors from WikibaseMalformedResponseException
- 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 byApiConnection.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 retrievedsites
- 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 titleprops
- 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 returnedsitefilter
- 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 errorIOException
- if we encounter network errors, or HTTP 500 errors on Wikibase's sideIllegalArgumentException
- if the given combination of parameters does not make senseMalformedResponseException
- if one of the returned entities cannot be parsed
-