Page MenuHomePhabricator

Define JS API to use Wikibase client
Open, Needs TriagePublic

Description

I would like to have a formal definition for JS API to access Wikibase from client which will be documented somewhere (https://www.mediawiki.org/wiki/Extension:Wikibase_Client or subpage) and will be stable way to acess API.

Below are some valid options, and it's totally fine if we don't want to commit to them to define a new dedicated module ("wikibase.api").

// Option 1 (was working few months ago)
mw.loader.using( [ 'wikibase.api.RepoApi', 'wikibase.client.getMwApiForRepo' ] ).done(function() {
			var wikidataApi = new wikibase.api.RepoApi(wikibase.client.getMwApiForRepo());
}
// Option 2 (works now)
mw.loader.using( [ 'wikibase.api.RepoApi', 'mw.config.values.wbRepo' ] ).done(function(){
			var repoConfig = mw.config.get( 'wbRepo' );
			var repoApi = new wikibase.api.RepoApi( wikibase.api.getLocationAgnosticMwApi(repoConfig.url + repoConfig.scriptPath + '/api.php') );