Get started with wikibase-sdk CDN

MIT licensed

PHP SDK: Wikibase-sdk for Wikibase collaboration platform interaction.

Tags:
  • wikidata
  • wikibase
  • sdk
  • api
  • wdq
  • sparql
  • wbk

Stable version

Copied!

How to start using wikibase-sdk CDN


// Include the Wikibase SDK from the CDN
const Wikibase = await import('https://cdn.cdnhub.io/wikibase-sdk/10.0.2/wikibase-sdk.min.js');

// Initialize the SDK with your Wikidata site and API access token
const wikibase = new Wikibase({
  site: 'wikidata.org',
  apiToken: 'YOUR_API_TOKEN_HERE'
});

// Define a function to perform a query
async function query(queryString) {
  try {
    const queryResult = await wikibase.data.get(queryString);
    console.log('Query result:', queryResult);
  } catch (error) {
    console.error('Error:', error);
  }
}

// Perform a query for items with the label "Eiffel Tower"
query('SELECT ?itemLabel WHERE { wd:Q185 wdt:P31 wd:Q2795 . ?item wdt:P31 wd:Q279 . ?item wdt:P361 ?property . ?property p:Label ?itemLabel FILTER(lang(?itemLabel)="en") }');

All versions