Since T125353: Make SPARQL endpoint discoverable using Wikibase API, the URL of the SPARQL endpoint associated to a Wikibase is exposed in SiteInfo (as wikibase-sparql).
However, that is not made available on Wikibase Cloud instances, per https://addshore-alpha.wikibase.cloud/wiki/Special:ApiSandbox#action=query&format=json&prop=info&meta=siteinfo (note the lack of wikibase-sparql)
This would made it easier to make tools work with Wikibases − in my case, for T294892: integraality for Wikibases?)
(As a tool developer, I want to find the SPARQL endpoint associated with a Wikibase, so that I can make my tool easily work with other Wikibases than Wikidata).
The setting within Wikibase extension is:
$wgWBRepoSettings['sparqlEndpoint']
hint
You can see how we trivially build this url for WikibaseManifest at https://github.com/wbstack/mediawiki/blob/main/dist-persist/wbstack/src/Settings/LocalSettings.php#L655 and this value could simply be duplicated to $wgWBRepoSettings['sparqlEndpoint']