Wikibase/API

Moved to Extension:Wikibase/API3

Modules
There are some parameters that is always available...

Plural forms are used in those cases where a parameter can take several values.


 * id|ids : Identifies a specific item or items.
 * site|sites ∩ title|titles : Identifies a single item or multiple items. Both sites and titles can't have multiple values at the same time.
 * language : The language is used as a filter mechanism to filter labels and descriptions in get actions or to identify a specific language for set actions.
 * format : Should always be set to json (or jsonfm for debygging)

Normally the return value either has a success key with a boolean cast as an integer or an error key with an object of two, optionally three, keys code, info and "*". The last one is additional information. Information about the action is either passed on the top level or under item if its one single item or items if its several. If it is several items each is found under a key with its own item id.

Note that empty objects are returned as arrays and not as objects.

wbgetitemid
getItemId( site, title )
 * Example : http://localhost/repo/api.php?action=wbgetitemid&title=Wikimedia&site=nn&format=jsonfm
 * Returns the found structure on a short form

{ 	"item": { "id": "44" }, 	"success": 1 }

wblinksite
linkSite( ( id XOR ( site, title ) ), linksite, linktitle *badge, *summary) { 	"success": 1, "item": { "id": 47 } }
 * Example : http://localhost/repo/api.php?action=wblinksite&site=no&title=Foo&linksite=no&linktitle=Mickepedia&format=jsonfm&link=set
 * Returns the identifier for the found site after update

{ 	"success": 1, "item": { "id": 47 } }
 * Example : http://localhost/repo/api.php?action=wblinksite&id=47&linksite=no&linktitle=Foo&format=jsonfm&link=set
 * Returns the identifier for the found site after update

Note that adding multiple links to a single external page will result in a database error and a previously stored erroneous structure on the page wil keep on triggering the database error. { 	"error": { "code": "internal_api_error_DBQueryError", "info": "Exception Caught: A database error has occurred. ...", "*": "\n\n#0 \/home\/john\/Workspace\/core\/includes\/db\/Database.php(904): DatabaseBase->reportQueryError('Duplicate entry...'" 	} }

wbsetlanguageattribute
setLanguageAttribute(id XOR (site, title), (label OR description), "update"|"add", *summary)
 * "update" throws an error if no value exists
 * "add" will throw an error if the value already exists
 * "set" always works
 * Example : http://localhost/repo/api.php?action=wbsetlanguageattribute&id=52&language=sv&label=Neverland&format=jsonfm&item=set
 * Returns the identifier for the changed item

{ 	"success": 1, "item": { "id": 52 } }

{ 	"success": 1, "item": { "id": 52 } }
 * Example : http://localhost/repo/api.php?action=wbsetlanguageattribute&id=52&language=sv&description=Place%20where%20Alice%20lived%20for%20a%20short%20time&format=jsonfm&item=set

wbdeletelanguageattribute (missing)

 * Not implemented

deleteLanguageAttribute(id XOR (site, title), attribute, *summary)

wbgetsitelinks
getSiteLinks( ( id XOR ( site, title ) )
 * Example : http://localhost/repo/api.php?action=wbgetsitelinks&id=46&format=jsonfm
 * Returns the found structure

{ 	"item": { "id": 46, "sitelinks": { "sv": "Mediawiki", "no": "Mediawiki" } 	}, 	"success": 1 }


 * Example : http://localhost/repo/api.php?action=wbgetsitelinks&site=no&title=Mediawiki&format=jsonfm
 * Returns the found structure

{ 	"item": { "id": "46", "sitelinks": { "sv": "Mediawiki", "no": "Mediawiki" } 	}, 	"success": 1 }

Note that it seems like some structures can't be found, and it seems like this correlates with previous errors from the database about conflicting ids.

getitems
getItems( ( ids XOR ( sites, titles )) ), *language)
 * Example : http://localhost/repo/api.php?action=wbgetitems&ids=46&format=jsonfm
 * Returns the found structure

{ 	"items": { "46": { 			"id": 46, "sitelinks": [ ], 			"descriptions": [ ], 			"labels": { "de": "de-value", "en": "en-value" } 		} 	}, 	"success": 1 }


 * Example : http://localhost/repo/api.php?action=wbgetitems&sites=nn&titles=Mediawiki&format=jsonfm

Note that naming deviates slightly from the proposed one getItems( ( ListOfIds XOR ( ListOfSites, ListOfTitles )) ), *language)

setitem
getItems( data )
 * Example : http://localhost/repo/api.php?action=wbsetitem&data={}&format=jsonfm
 * Builds a structure like this (it returns the created structure)

{ 	"item": { "id": 49, // this is item that is automatically added "sitelinks": [ // note that there is an array here as it an empty object ], 		"descriptions": [ // note that there is an array here as it an empty object ], 		"labels": [ // note that there is an array here as it an empty object ] 	}, 	"success": 1 }

{ 	"item": { "id": 50, // this is item that is automatically added "sitelinks": [ // note that there is an array here as it an empty object ], 		"descriptions": [ // note that there is an array here as it an empty object ], 		"labels": { "de": "de-value", "en": "en-value" } 	}, 	"success": 1 }
 * Example : http://localhost/repo/api.php?action=wbsetitem&data={%22label%22:{%22de%22:{%22language%22:%22de%22,%22value%22:%22de-value%22},%22en%22:{%22language%22:%22en%22,%22value%22:%22en-value%22}}}&format=jsonfm

setalias (partly)
setAliases(id XOR (site, title), (add OR remove) XOR set, *summary) ''This call is somewhat confusing and is at present implemented as  where site and title double as linksite and linktitle. This is probably wrong. It should be local calls, somewhat a type of local redirect. This is not implemented for the moment.''
 * Example : http://localhost/repo/api.php?action=wbsetalias&id=44&language=en&site=nn&title=Wikimedia&summary=World%20domination%20will%20be%20mine%20soon!&format=jsonfm

wbsearchbyname (partly)
This call is only partly implemented as it is not clear how the search should be done. searchByName(language, fragment, *hints)