CINXE.COM
Wikidata Query Service/User Manual - MediaWiki
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-disabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Wikidata Query Service/User Manual - MediaWiki</title> <script>(function(){var className="client-js vector-feature-language-in-header-disabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )mediawikiwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""], "wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"7048e307-f0a3-4eb3-a372-eb0288e6a6d7","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Wikidata_Query_Service/User_Manual","wgTitle":"Wikidata Query Service/User Manual","wgCurRevisionId":6711618,"wgRevisionId":6711618,"wgArticleId":491213,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Wikidata Query Service","Discovery","Wikidata","SPARQL"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Wikidata_Query_Service/User_Manual","wgRelevantArticleId":491213,"wgIsProbablyEditable":false,"wgRelevantPageIsProbablyEditable":false,"wgRestrictionEdit":["autoconfirmed"],"wgRestrictionMove":["autoconfirmed"],"wgNoticeProject":"mediawiki", "wgCiteReferencePreviewsActive":true,"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":60000,"wgInternalRedirectTargetUrl":"/wiki/Wikidata_Query_Service/User_Manual","wgTranslatePageTranslation":"source","wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgDiscussionToolsFeaturesEnabled":{"replytool":true,"newtopictool":true,"sourcemodetoolbar":true,"topicsubscription":false,"autotopicsub":false,"visualenhancements":false,"visualenhancements_reply":false,"visualenhancements_pageframe":false},"wgDiscussionToolsFallbackEditMode":"visual","wgULSPosition":"personal","wgULSisCompactLinksEnabled":true,"wgVector2022LanguageInHeader":false,"wgULSisLanguageSelectorEmpty":false, "wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"]};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.translate.tag.languages":"ready","ext.pygments":"ready","ext.tmh.player.styles":"ready","ext.discussionTools.init.styles":"ready","oojs-ui-core.styles":"ready","oojs-ui.styles.indicators":"ready","mediawiki.widgets.styles":"ready","oojs-ui-core.icons":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.translate.edit.documentation.styles":"ready","ext.translate":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.pt":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["mediawiki.action.view.redirect","ext.pygments.view", "mediawiki.page.media","ext.tmh.player","site","mediawiki.page.ready","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.translate.pagetranslation.uls","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.discussionTools.init","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.compactlinks","ext.uls.interface","ext.checkUser.clientHints"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.discussionTools.init.styles%7Cext.pygments%2Ctranslate%2CwikimediaBadges%7Cext.tmh.player.styles%7Cext.translate.edit.documentation.styles%7Cext.translate.tag.languages%7Cext.uls.pt%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cmediawiki.widgets.styles%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui.styles.indicators%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Wikidata_Sparql_Query_Tutorial.webm/1200px--Wikidata_Sparql_Query_Tutorial.webm.jpg"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="675"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Wikidata_Sparql_Query_Tutorial.webm/800px--Wikidata_Sparql_Query_Tutorial.webm.jpg"> <meta property="og:image:width" content="800"> <meta property="og:image:height" content="450"> <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Wikidata_Sparql_Query_Tutorial.webm/640px--Wikidata_Sparql_Query_Tutorial.webm.jpg"> <meta property="og:image:width" content="640"> <meta property="og:image:height" content="360"> <meta name="viewport" content="width=1120"> <meta property="og:site_name" content="MediaWiki"> <meta property="og:title" content="Wikidata Query Service/User Manual - MediaWiki"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//m.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual"> <link rel="apple-touch-icon" href="/static/apple-touch/mediawiki.png"> <link rel="icon" href="/static/favicon/mediawiki.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="MediaWiki (en)"> <link rel="EditURI" type="application/rsd+xml" href="//www.mediawiki.org/w/api.php?action=rsd"> <link rel="canonical" href="https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"> <link rel="alternate" type="application/atom+xml" title="MediaWiki Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="ext-discussiontools-replytool-enabled ext-discussiontools-newtopictool-enabled ext-discussiontools-sourcemodetoolbar-enabled skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Wikidata_Query_Service_User_Manual rootpage-Wikidata_Query_Service skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/MediaWiki" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-mw-download" class="mw-list-item"><a href="/wiki/Download"><span>Get MediaWiki</span></a></li><li id="n-mw-extensions" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Category:Extensions"><span>Get extensions</span></a></li><li id="n-blog-text" class="mw-list-item"><a href="https://techblog.wikimedia.org/"><span>Tech blog</span></a></li><li id="n-mw-contribute" class="mw-list-item"><a href="/wiki/Special:MyLanguage/How_to_contribute"><span>Contribute</span></a></li> </ul> </div> </div> <div id="p-support" class="vector-menu mw-portlet mw-portlet-support" > <div class="vector-menu-heading"> Support </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Help:Contents" title="The place to find out"><span>User help</span></a></li><li id="n-mw-faq" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Manual:FAQ"><span>FAQ</span></a></li><li id="n-mw-manual" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Manual:Contents"><span>Technical manual</span></a></li><li id="n-mw-supportdesk" class="mw-list-item"><a href="/wiki/Project:Support_desk"><span>Support desk</span></a></li><li id="n-mw-communication" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Communication"><span>Communication</span></a></li> </ul> </div> </div> <div id="p-development" class="vector-menu mw-portlet mw-portlet-development" > <div class="vector-menu-heading"> Development </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mw-developerportal" class="mw-list-item"><a href="https://developer.wikimedia.org/"><span>Developer portal</span></a></li><li id="n-svn-statistics" class="mw-list-item"><a href="/wiki/Development_statistics"><span>Code statistics</span></a></li> </ul> </div> </div> <div id="p-mediawiki.org" class="vector-menu mw-portlet mw-portlet-mediawiki_org" > <div class="vector-menu-heading"> mediawiki.org </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-portal" class="mw-list-item"><a href="/wiki/Project:Help" title="About the project, what you can do, where to find things"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-mw-translate" class="mw-list-item"><a href="/wiki/Special:LanguageStats"><span>Translate content</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Load a random page [x]" accesskey="x"><span>Random page</span></a></li><li id="n-mw-discussion" class="mw-list-item"><a href="/wiki/Project:Village_Pump"><span>Village pump</span></a></li><li id="n-Sandboxlink-portlet-label" class="mw-list-item"><a href="/wiki/Project:Sandbox"><span>Sandbox</span></a></li> </ul> </div> </div> <div id="p-lang" class="vector-menu mw-portlet mw-portlet-lang" > <div class="vector-menu-heading"> In other languages </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-add wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:NewItem?site=mediawikiwiki&page=Wikidata+Query+Service%2FUser+Manual" title="Add interlanguage links" class="wbc-editpage">Add links</a></span></div> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/MediaWiki" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/mediawikiwiki.svg" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="MediaWiki" src="/static/images/mobile/copyright/mediawikiwiki-wordmark.svg" style="width: 7.5em; height: 1.125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search MediaWiki [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search MediaWiki" aria-label="Search MediaWiki" autocapitalize="sentences" title="Search MediaWiki [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-uls" class="mw-list-item active user-links-collapsible-item"><a data-mw="interface" href="#" class="uls-trigger cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>English</span></a> </li> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?utm_source=donate&utm_medium=sidebar&utm_campaign=spontaneous&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=Wikidata+Query+Service%2FUser+Manual" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=Wikidata+Query+Service%2FUser+Manual" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="More options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?utm_source=donate&utm_medium=sidebar&utm_campaign=spontaneous&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Wikidata+Query+Service%2FUser+Manual" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Wikidata+Query+Service%2FUser+Manual" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">Beginning</div> </a> </li> <li id="toc-Data_set" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Data_set"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Data set</span> </div> </a> <ul id="toc-Data_set-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic_Triple" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic_Triple"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Basics - Understanding SPO (Subject, Predicate, Object) also known as a Semantic Triple</span> </div> </a> <ul id="toc-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic_Triple-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Basics_-_Understanding_Prefixes" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Basics_-_Understanding_Prefixes"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Basics - Understanding Prefixes</span> </div> </a> <ul id="toc-Basics_-_Understanding_Prefixes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Extensions" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Extensions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Extensions</span> </div> </a> <button aria-controls="toc-Extensions-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Extensions subsection</span> </button> <ul id="toc-Extensions-sublist" class="vector-toc-list"> <li id="toc-Label_service" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Label_service"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Label service</span> </div> </a> <ul id="toc-Label_service-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Geospatial_search" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Geospatial_search"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Geospatial search</span> </div> </a> <ul id="toc-Geospatial_search-sublist" class="vector-toc-list"> <li id="toc-Search_around_point" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Search_around_point"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2.1</span> <span>Search around point</span> </div> </a> <ul id="toc-Search_around_point-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Search_within_box" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Search_within_box"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2.2</span> <span>Search within box</span> </div> </a> <ul id="toc-Search_within_box-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Extended_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Extended_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Extended functions</span> </div> </a> <ul id="toc-Extended_functions-sublist" class="vector-toc-list"> <li id="toc-Distance_function" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Distance_function"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3.1</span> <span>Distance function</span> </div> </a> <ul id="toc-Distance_function-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Coordinate_parts_functions" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Coordinate_parts_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3.2</span> <span>Coordinate parts functions</span> </div> </a> <ul id="toc-Coordinate_parts_functions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Decode_URL_functions" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Decode_URL_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3.3</span> <span>Decode URL functions</span> </div> </a> <ul id="toc-Decode_URL_functions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Automatic_prefixes" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Automatic_prefixes"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.4</span> <span>Automatic prefixes</span> </div> </a> <ul id="toc-Automatic_prefixes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Extended_dates" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Extended_dates"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.5</span> <span>Extended dates</span> </div> </a> <ul id="toc-Extended_dates-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Blazegraph_extensions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Blazegraph_extensions"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.6</span> <span>Blazegraph extensions</span> </div> </a> <ul id="toc-Blazegraph_extensions-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Federation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Federation"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.7</span> <span>Federation</span> </div> </a> <ul id="toc-Federation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-MediaWiki_API" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#MediaWiki_API"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.8</span> <span>MediaWiki API</span> </div> </a> <ul id="toc-MediaWiki_API-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Wikimedia_service" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Wikimedia_service"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Wikimedia service</span> </div> </a> <button aria-controls="toc-Wikimedia_service-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Wikimedia service subsection</span> </button> <ul id="toc-Wikimedia_service-sublist" class="vector-toc-list"> <li id="toc-GUI" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#GUI"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>GUI</span> </div> </a> <ul id="toc-GUI-sublist" class="vector-toc-list"> <li id="toc-Default_views" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Default_views"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1.1</span> <span>Default views</span> </div> </a> <ul id="toc-Default_views-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Display_a_title" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Display_a_title"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1.2</span> <span>Display a title</span> </div> </a> <ul id="toc-Display_a_title-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-SPARQL_endpoint" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#SPARQL_endpoint"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>SPARQL endpoint</span> </div> </a> <ul id="toc-SPARQL_endpoint-sublist" class="vector-toc-list"> <li id="toc-Supported_formats" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Supported_formats"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.1</span> <span>Supported formats</span> </div> </a> <ul id="toc-Supported_formats-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Query_limits" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Query_limits"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.2</span> <span>Query limits</span> </div> </a> <ul id="toc-Query_limits-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Explain_Query" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Explain_Query"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.3</span> <span>Explain Query</span> </div> </a> <ul id="toc-Explain_Query-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Namespaces" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Namespaces"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.3</span> <span>Namespaces</span> </div> </a> <ul id="toc-Namespaces-sublist" class="vector-toc-list"> <li id="toc-Categories" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Categories"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.3.1</span> <span>Categories</span> </div> </a> <ul id="toc-Categories-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-DCAT-AP" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#DCAT-AP"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.3.2</span> <span>DCAT-AP</span> </div> </a> <ul id="toc-DCAT-AP-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Linked_Data_Fragments_endpoint" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Linked_Data_Fragments_endpoint"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.4</span> <span>Linked Data Fragments endpoint</span> </div> </a> <ul id="toc-Linked_Data_Fragments_endpoint-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Standalone_service" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Standalone_service"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Standalone service</span> </div> </a> <button aria-controls="toc-Standalone_service-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Standalone service subsection</span> </button> <ul id="toc-Standalone_service-sublist" class="vector-toc-list"> <li id="toc-Installing" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Installing"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1</span> <span>Installing</span> </div> </a> <ul id="toc-Installing-sublist" class="vector-toc-list"> <li id="toc-Using_snapshot_versions" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Using_snapshot_versions"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.1.1</span> <span>Using snapshot versions</span> </div> </a> <ul id="toc-Using_snapshot_versions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Loading_data" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Loading_data"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2</span> <span>Loading data</span> </div> </a> <ul id="toc-Loading_data-sublist" class="vector-toc-list"> <li id="toc-Loading_categories" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Loading_categories"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.2.1</span> <span>Loading categories</span> </div> </a> <ul id="toc-Loading_categories-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Scripts" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Scripts"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3</span> <span>Scripts</span> </div> </a> <ul id="toc-Scripts-sublist" class="vector-toc-list"> <li id="toc-munge.sh" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#munge.sh"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3.1</span> <span>munge.sh</span> </div> </a> <ul id="toc-munge.sh-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-loadData.sh" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#loadData.sh"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3.2</span> <span>loadData.sh</span> </div> </a> <ul id="toc-loadData.sh-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-runBlazegraph.sh" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#runBlazegraph.sh"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3.3</span> <span>runBlazegraph.sh</span> </div> </a> <ul id="toc-runBlazegraph.sh-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-runUpdate.sh" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#runUpdate.sh"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.3.4</span> <span>runUpdate.sh</span> </div> </a> <ul id="toc-runUpdate.sh-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Updater_options" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Updater_options"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.4</span> <span>Updater options</span> </div> </a> <ul id="toc-Updater_options-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Configurable_properties" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Configurable_properties"> <div class="vector-toc-text"> <span class="vector-toc-numb">6.5</span> <span>Configurable properties</span> </div> </a> <ul id="toc-Configurable_properties-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Missing_features" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Missing_features"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Missing features</span> </div> </a> <ul id="toc-Missing_features-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Contacts" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Contacts"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>Contacts</span> </div> </a> <ul id="toc-Contacts-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Wikidata Query Service/User Manual</span></h1> <div class="mw-indicators"> <div id="mw-indicator-phabricator-project" class="mw-indicator"><div class="mw-parser-output"><div class="mw-parser-output"><style data-mw-deduplicate="TemplateStyles:r6605561">.mw-parser-output .tpl-badge{background-color:var(--background-color-progressive-subtle,#eaf3ff);color:var(--color-base,#202122);border-radius:10px;display:inline-block;font-size:90%;padding:5px 8px}</style><div class="tpl-badge"><a href="/wiki/Special:MyLanguage/Phabricator" title="Special:MyLanguage/Phabricator">Issue tracker</a>: <a href="https://phabricator.wikimedia.org/tag/wdqs/" class="extiw" title="phab:tag/wdqs/"><b>#WDQS</b></a></div></div></div></div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Wikidata_Query_Service/User_Manual" title="View the content page [c]" accesskey="c"><span>Page</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Wikidata_Query_Service/User_Manual" rel="discussion" title="Discussion about the content page [t]" accesskey="t"><span>Discussion</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Wikidata_Query_Service/User_Manual"><span>Read</span></a></li><li id="ca-viewsource" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&action=edit" title="This page is protected. You can view its source [e]" accesskey="e"><span>View source</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Wikidata_Query_Service/User_Manual"><span>Read</span></a></li><li id="ca-more-viewsource" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&action=edit"><span>View source</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Wikidata_Query_Service/User_Manual" title="A list of all wiki pages that link here [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Wikidata_Query_Service/User_Manual" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//commons.wikimedia.org/wiki/Special:UploadWizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&oldid=6711618" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=Wikidata_Query_Service%2FUser_Manual&id=6711618&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fwww.mediawiki.org%2Fwiki%2FWikidata_Query_Service%2FUser_Manual"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fwww.mediawiki.org%2Fwiki%2FWikidata_Query_Service%2FUser_Manual"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-create_a_book" class="mw-list-item"><a href="/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Wikidata+Query+Service%2FUser+Manual"><span>Create a book</span></a></li><li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=Wikidata_Query_Service%2FUser_Manual&action=show-download-screen"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Wikidata_Query_Service/User_Manual&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects emptyPortlet" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div id="siteSub" class="noprint">From mediawiki.org</div> </div> <div id="contentSub"><div id="mw-content-subtitle"><div class="subpages">< <bdi dir="ltr"><a href="/wiki/Special:MyLanguage/Wikidata_Query_Service" title="Special:MyLanguage/Wikidata Query Service">Wikidata Query Service</a></bdi></div></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-pt-translate-header noprint nomobile" dir="ltr" lang="en"><a href="/w/index.php?title=Special:Translate&group=page-Wikidata+Query+Service%2FUser+Manual&action=page&filter=&action_source=translate_page" title="Special:Translate">Translate this page</a></div><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="mw-pt-languages noprint navigation-not-searchable" lang="en" dir="ltr"><div class="mw-pt-languages-label">Languages:</div><ul class="mw-pt-languages-list"><li><a href="/wiki/Wikidata_Query_Service/User_Manual/de" class="mw-pt-progress mw-pt-progress--high" title="Wikidata Query Service/Bedienungsanleitung (72% translated)" lang="de" dir="ltr">Deutsch</a></li> <li><span class="mw-pt-languages-ui mw-pt-languages-selected mw-pt-progress mw-pt-progress--complete" lang="en" dir="ltr">English</span></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/tr" class="mw-pt-progress mw-pt-progress--high" title="Vikiveri Sorgulama Hizmeti/Kullanıcı Kılavuzu (74% translated)" lang="tr" dir="ltr">Türkçe</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/yo" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/yo (0% translated)" lang="yo" dir="ltr">Yorùbá</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/ca" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/Manual d'usuari (3% translated)" lang="ca" dir="ltr">català</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/da" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/da (11% translated)" lang="da" dir="ltr">dansk</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/es" class="mw-pt-progress mw-pt-progress--med" title="Wikidata Query Service/Manual del Usuario (21% translated)" lang="es" dir="ltr">español</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/eu" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/eu (0% translated)" lang="eu" dir="ltr">euskara</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/fr" class="mw-pt-progress mw-pt-progress--high" title="Service de requête Wikidata/Manuel utilisateur (94% translated)" lang="fr" dir="ltr">français</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/it" class="mw-pt-progress mw-pt-progress--low" title="Wikidata query service/Manuale utente (3% translated)" lang="it" dir="ltr">italiano</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/hu" class="mw-pt-progress mw-pt-progress--low" title="Wikidata-lekérdezések/Használati útmutató (11% translated)" lang="hu" dir="ltr">magyar</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/pl" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/pl (13% translated)" lang="pl" dir="ltr">polski</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/pt-br" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/Manual de usuário (1% translated)" lang="pt-BR" dir="ltr">português do Brasil</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/sv" class="mw-pt-progress mw-pt-progress--low" title="Wikidatas frågetjänst/Användarmanual (1% translated)" lang="sv" dir="ltr">svenska</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/cs" class="mw-pt-progress mw-pt-progress--complete" title="Wikidata Query Service/Uživatelská příručka (100% translated)" lang="cs" dir="ltr">čeština</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/el" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/el (0% translated)" lang="el" dir="ltr">Ελληνικά</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/be-tarask" class="mw-pt-progress mw-pt-progress--low" title="Служба запытаў Вікізьвестак/Інструкцыя карыстальніка (5% translated)" lang="be-tarask" dir="ltr">беларуская (тарашкевіца)</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/mk" class="mw-pt-progress mw-pt-progress--low" title="Побарувачка служба на Википодатоците/Прирачник (0% translated)" lang="mk" dir="ltr">македонски</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/ru" class="mw-pt-progress mw-pt-progress--med" title="Wikidata Query Service/User Manual/ru (18% translated)" lang="ru" dir="ltr">русский</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/uk" class="mw-pt-progress mw-pt-progress--med" title="Wikidata Query Service/Посібник користувача (18% translated)" lang="uk" dir="ltr">українська</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/yi" class="mw-pt-progress mw-pt-progress--low" title="Wikidata Query Service/User Manual/yi (3% translated)" lang="yi" dir="rtl">ייִדיש</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/hi" class="mw-pt-progress mw-pt-progress--low" title="विकिडेटा क्वेरी सेवा/सदस्य मैन्युअल (4% translated)" lang="hi" dir="ltr">हिन्दी</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/bn" class="mw-pt-progress mw-pt-progress--low" title="উইকিউপাত্ত কুয়ারি পরিষেবা/ ব্যবহারকারী ম্যানুয়াল (1% translated)" lang="bn" dir="ltr">বাংলা</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/ta" class="mw-pt-progress mw-pt-progress--low" title="விக்கித்தகவல்கள் கேள்வி சேவை/பயனர் கையேடு (0% translated)" lang="ta" dir="ltr">தமிழ்</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/th" class="mw-pt-progress mw-pt-progress--low" title="การบริการของวิกิพีเดียและคู่มือการใช้งาน (1% translated)" lang="th" dir="ltr">ไทย</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/zh" class="mw-pt-progress mw-pt-progress--low" title="维基数据查询服务/用户手册 (5% translated)" lang="zh" dir="ltr">中文</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/ja" class="mw-pt-progress mw-pt-progress--high" title="ウィキデータ クエリ サービス/利用者マニュアル (99% translated)" lang="ja" dir="ltr">日本語</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/yue" class="mw-pt-progress mw-pt-progress--low" title="維基數據查詢服務/用戶手冊 (1% translated)" lang="yue" dir="ltr">粵語</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/nan" class="mw-pt-progress mw-pt-progress--low" title="Uikidata Tsa-sûn Ho̍k-bū/Iōng-tsiá Tshiú-tsheh (6% translated)" lang="nan" dir="ltr">閩南語 / Bân-lâm-gú</a></li> <li><a href="/wiki/Wikidata_Query_Service/User_Manual/ko" class="mw-pt-progress mw-pt-progress--med" title="위키데이터 쿼리 서비스/사용자 매뉴얼 (15% translated)" lang="ko" dir="ltr">한국어</a></li></ul></div> <figure typeof="mw:File/Thumb"><span><video id="mwe_player_0" poster="//upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Wikidata_Sparql_Query_Tutorial.webm/300px--Wikidata_Sparql_Query_Tutorial.webm.jpg" controls="" preload="none" data-mw-tmh="" class="mw-file-element" width="300" height="169" data-durationhint="985" data-mwtitle="Wikidata_Sparql_Query_Tutorial.webm" data-mwprovider="wikimediacommons" resource="/wiki/File:Wikidata_Sparql_Query_Tutorial.webm"><source src="//upload.wikimedia.org/wikipedia/commons/transcoded/5/5a/Wikidata_Sparql_Query_Tutorial.webm/Wikidata_Sparql_Query_Tutorial.webm.480p.vp9.webm" type="video/webm; codecs="vp9, opus"" data-transcodekey="480p.vp9.webm" data-width="854" data-height="480"/><source src="//upload.wikimedia.org/wikipedia/commons/transcoded/5/5a/Wikidata_Sparql_Query_Tutorial.webm/Wikidata_Sparql_Query_Tutorial.webm.720p.vp9.webm" type="video/webm; codecs="vp9, opus"" data-transcodekey="720p.vp9.webm" data-width="1280" data-height="720"/><source src="//upload.wikimedia.org/wikipedia/commons/5/5a/Wikidata_Sparql_Query_Tutorial.webm" type="video/webm; codecs="vp8, vorbis"" data-width="1280" data-height="720"/><source src="//upload.wikimedia.org/wikipedia/commons/transcoded/5/5a/Wikidata_Sparql_Query_Tutorial.webm/Wikidata_Sparql_Query_Tutorial.webm.240p.vp9.webm" type="video/webm; codecs="vp9, opus"" data-transcodekey="240p.vp9.webm" data-width="426" data-height="240"/><source src="//upload.wikimedia.org/wikipedia/commons/transcoded/5/5a/Wikidata_Sparql_Query_Tutorial.webm/Wikidata_Sparql_Query_Tutorial.webm.360p.vp9.webm" type="video/webm; codecs="vp9, opus"" data-transcodekey="360p.vp9.webm" data-width="640" data-height="360"/><source src="//upload.wikimedia.org/wikipedia/commons/transcoded/5/5a/Wikidata_Sparql_Query_Tutorial.webm/Wikidata_Sparql_Query_Tutorial.webm.360p.webm" type="video/webm; codecs="vp8, vorbis"" data-transcodekey="360p.webm" data-width="640" data-height="360"/></video></span><figcaption>A 15-min Wikidata Query Service tutorial</figcaption></figure> <p><a href="/wiki/Special:MyLanguage/Wikidata_Query_Service" title="Special:MyLanguage/Wikidata Query Service">Wikidata Query Service</a> (WDQS) is a software package and public service designed to provide a <a href="https://en.wikipedia.org/wiki/SPARQL" class="extiw" title="w:SPARQL">SPARQL</a> endpoint which allows you to query against the <a href="https://www.wikidata.org/wiki/" class="extiw" title="wikidata:">Wikidata</a> data set. </p><p>This page or other relevant documentation pages will be updated accordingly; it is recommended that you watch them if you are using the service. </p><p>You can see examples of the SPARQL Queries on the <a href="https://www.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_query_service/queries/examples" class="extiw" title="d:Special:MyLanguage/Wikidata:SPARQL query service/queries/examples">SPARQL examples page</a>. </p> <meta property="mw:PageProp/toc"/> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Data_set" data-mw-thread-id="h-Data_set"><span data-mw-comment-start="" id="h-Data_set"></span>Data set<span data-mw-comment-end="h-Data_set"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Data_set","replies":[]}}--></div> <p>The Wikidata Query Service operates on a data set from Wikidata.org, represented in RDF as described in the <a href="/wiki/Wikibase/Indexing/RDF_Dump_Format" title="Wikibase/Indexing/RDF Dump Format">RDF dump format</a> documentation. </p><p>The service's data set does not exactly match the data set produced by RDF dumps, mainly for performance reasons; the documentation describes a small set of differences. </p><p>You can download a weekly dump of the same data from: </p><p><a class="external free" href="https://dumps.wikimedia.org/wikidatawiki/entities/">https://dumps.wikimedia.org/wikidatawiki/entities/</a> </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic_Triple" data-mw-thread-id="h-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic"><span id="Basics_-_Understanding_SPO_.28Subject.2C_Predicate.2C_Object.29_also_known_as_a_Semantic_Triple"></span><span data-mw-comment-start="" id="h-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic"></span>Basics - Understanding SPO (Subject, Predicate, Object) also known as a Semantic Triple<span data-mw-comment-end="h-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic","replies":[]}}--></div> <p>spo or "subject, predicate, object" is known as a <a href="https://en.wikipedia.org/wiki/Semantic_triple" class="extiw" title="w:Semantic triple">triple</a>, or commonly referred to in Wikidata as a <b>statement</b> about data. </p><p>The statement "The United States capital is Washington DC" consists of the subject "United States" (<a href="https://www.wikidata.org/wiki/Q30" class="extiw" title="wikidata:Q30">Q30</a>), the predicate "capital is" (<a href="https://www.wikidata.org/wiki/property:P36" class="extiw" title="wikidata:property:P36">P36</a>), and an object "Washington DC" (<a href="https://www.wikidata.org/wiki/Q61" class="extiw" title="wikidata:Q61">Q61</a>). This statement can be represented as three URIs: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="nl"><http://www.wikidata.org/entity/Q30></span> <span class="nl"><http://www.wikidata.org/prop/direct/P36></span> <span class="nl"><http://www.wikidata.org/entity/Q61></span> <span class="p">.</span> </pre></div> <p>Thanks to the prefixes (see below), the same statement can be written in a more concise form. Note the dot at the end to represent the end of the statement. </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="nn">wd</span><span class="p">:</span><span class="nt">Q30</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P36</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q61</span> <span class="p">.</span> </pre></div> <p>The <b>/entity/</b> (<b>wd:</b>) represents Wikidata entity (Q-number values). The <b>/prop/direct/</b> (<b>wdt:</b>) is a "truthy" property — a value we would expect most often when looking at the statement. The truthy properties are needed because some statements could be "truer" than others. For example, the statement "The capital of U.S. is New York City" is true — but only in the historical context of the year 1790. WDQS uses rank to determine which statements should be used as "truthy". </p><p>In addition to the truthy statements, WDQS stores all statements (both truthy and not), but they don't use the same <b>wdt:</b> prefix. <a href="https://www.wikidata.org/wiki/Q30#P36" class="extiw" title="wikidata:Q30">U.S. capital</a> has three values: DC, Philadelphia, and New York. And each of these values have "qualifiers" - additional information, such as start and end dates, that narrows down the scope of each statement. To store this information in the triplestore, WDQS introduces an automatic "statement" subject, which is essentially a random number: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="nn">wd</span><span class="p">:</span><span class="nt">Q30</span> <span class="nn">p</span><span class="p">:</span><span class="nt">P36</span> <span class="nl"><random_URI_1></span> <span class="p">.</span> <span class="c"># US "indirect capital" is <X></span> <span class="nl"><random_URI_1></span> <span class="nn">ps</span><span class="p">:</span><span class="nt">P36</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q61</span> <span class="p">.</span> <span class="c"># The X's "real capital value" is Washington DC</span> <span class="nl"><random_URI_1></span> <span class="nn">pq</span><span class="p">:</span><span class="nt">P580</span> <span class="s">"1800-11-17"</span> <span class="p">.</span> <span class="c"># The X's start date is 1800-11-17</span> </pre></div> <p>See <a href="https://www.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_tutorial#Qualifiers" class="extiw" title="wikidata:Special:MyLanguage/Wikidata:SPARQL tutorial">SPARQL tutorial - qualifiers</a> for more information. </p><p>spo is also used as a form of basic syntax layout for querying <a href="https://en.wikipedia.org/wiki/Resource_Description_Framework" class="extiw" title="w:Resource Description Framework">RDF</a> data structures, or any graph database or triplestore, such as the Wikidata Query Service (WDQS), which is powered by Blazegraph, a high performance graph database. </p><p>Advanced uses of a triple (spo) even including using triples as objects or subjects of other triples! </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Basics_-_Understanding_Prefixes" data-mw-thread-id="h-Basics_-_Understanding_Prefixes"><span data-mw-comment-start="" id="h-Basics_-_Understanding_Prefixes"></span>Basics - Understanding Prefixes<span data-mw-comment-end="h-Basics_-_Understanding_Prefixes"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Basics_-_Understanding_Prefixes","replies":[]}}--></div> <p>The subjects and predicates (first and second values of the triple) must always be stored as <a href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier" class="extiw" title="w:Uniform Resource Identifier">URI</a>. For example, if the subject is <a href="https://www.wikidata.org/wiki/Q1" class="extiw" title="wikidata:Q1">Universe (Q1)</a>, it will be stored as <b><https://www.wikidata.org/wiki/Q1></b>. Prefixes allow us to write that long URI in a shorter form: <b>wd:Q1</b>. Unlike subjects and predicates, the object (triple's third value) can be either a URI or a literal, e.g. a number or a string. </p><p>WDQS understands many shortcut abbreviations, known as prefixes. Some are internal to Wikidata, e.g. <b>wd, wdt, p, ps, bd</b>, and many others are commonly used external prefixes, like <b>rdf, skos, owl, schema</b>. </p><p>In the following query, we are asking for items where there is a statement of "P279 = Q7725634" or in fuller terms, selecting subjects that have a predicate of "subclass of" with an object of = "literary work". </p><p>The output variables: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">PREFIX</span> <span class="nn">wd</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/entity/></span> <span class="k">PREFIX</span> <span class="nn">wds</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/entity/statement/></span> <span class="k">PREFIX</span> <span class="nn">wdv</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/value/></span> <span class="k">PREFIX</span> <span class="nn">wdt</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/prop/direct/></span> <span class="k">PREFIX</span> <span class="nn">wikibase</span><span class="p">:</span> <span class="nl"><http://wikiba.se/ontology#></span> <span class="k">PREFIX</span> <span class="nn">p</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/prop/></span> <span class="k">PREFIX</span> <span class="nn">ps</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/prop/statement/></span> <span class="k">PREFIX</span> <span class="nn">pq</span><span class="p">:</span> <span class="nl"><http://www.wikidata.org/prop/qualifier/></span> <span class="k">PREFIX</span> <span class="nn">rdfs</span><span class="p">:</span> <span class="nl"><http://www.w3.org/2000/01/rdf-schema#></span> <span class="k">PREFIX</span> <span class="nn">bd</span><span class="p">:</span> <span class="nl"><http://www.bigdata.com/rdf#></span> <span class="c"># The below SELECT query does the following:</span> <span class="c"># Selects all the items(?s subjects) and their labels(?label)</span> <span class="c"># that have(WHERE) the statement(?s subject) has a direct property(wdt:) = P279 <subclasses of></span> <span class="c"># with a value of entity(wd:) = Q7725634 <Literary Work></span> <span class="c"># and optionally return the English labels</span> <span class="k">SELECT</span> <span class="nv">?s</span> <span class="nv">?label</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nv">?s</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q7725634</span> <span class="p">.</span> <span class="k">OPTIONAL</span> <span class="p">{</span> <span class="nv">?s</span> <span class="nn">rdfs</span><span class="p">:</span><span class="nt">label</span> <span class="nv">?label</span> <span class="k">filter</span> <span class="p">(</span><span class="nf">lang</span><span class="p">(</span><span class="nv">?label</span><span class="p">)</span> <span class="o">=</span> <span class="s">"en"</span><span class="p">).</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Extensions" data-mw-thread-id="h-Extensions"><span data-mw-comment-start="" id="h-Extensions"></span>Extensions<span data-mw-comment-end="h-Extensions"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Extensions","replies":["h-Label_service-Extensions","h-Geospatial_search-Extensions","h-Extended_functions-Extensions","h-Automatic_prefixes-Extensions","h-Extended_dates-Extensions","h-Blazegraph_extensions-Extensions","h-Federation-Extensions","h-MediaWiki_API-Extensions"]}}--></div> <p>The service supports the following extensions to standard SPARQL capabilities: </p> <div class="mw-heading mw-heading3"><h3 id="Label_service" data-mw-thread-id="h-Label_service-Extensions"><span data-mw-comment-start="" id="h-Label_service-Extensions"></span>Label service<span data-mw-comment-end="h-Label_service-Extensions"></span></h3></div> <p>You can fetch the label, alias, or description of entities you query, with language fallback, using the specialized service with the URI <<a rel="nofollow" class="external free" href="http://wikiba.se/ontology#label">http://wikiba.se/ontology#label</a>>. The service is very helpful when you want to retrieve labels, as it reduces the complexity of SPARQL queries that you would otherwise need to achieve the same effect. </p><p>The service can be used in one of the two modes: manual and automatic. </p><p>In automatic mode, you only need to specify the service template, e.g.: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">PREFIX</span> <span class="nn">wikibase</span><span class="p">:</span> <span class="nl"><http://wikiba.se/ontology#></span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"en"</span> <span class="p">.</span> <span class="p">}</span> </pre></div> <p>and WDQS will automatically generate labels as follows: </p> <ul><li>If an unbound variable in <code>SELECT</code> is named <code>?<i>NAME</i>Label</code>, then WDQS produces the label (<code>rdfs:label</code>) for the entity in variable <code>?<i>NAME</i></code>.</li> <li>If an unbound variable in <code>SELECT</code> is named <code>?<i>NAME</i>AltLabel</code>, then WDQS produces the alias (<code>skos:altLabel</code>) for the entity in variable <code>?<i>NAME</i></code>.</li> <li>If an unbound variable in <code>SELECT</code> is named <code>?<i>NAME</i>Description</code>, then WDQS produces the description (<code>schema:description</code>) for the entity in variable <code>?<i>NAME</i></code>.</li></ul> <p>In each case, the variable in <code>?<i>NAME</i></code> should be bound, otherwise the service fails. </p><p>Automatic mode only inspects the projection of the query – for instance, in <code>SELECT ?aLabel (GROUP_CONCAT(?bLabel) AS ?bLabels)</code>, only the first label is recognized, and <code>SELECT *</code> is not supported by automatic mode at all. In such cases, you will need to use manual mode (see below). </p><p>You specify your preferred language(s) for the label with one or more of <code>bd:serviceParam wikibase:language "<i>language-code</i>"</code> triples. Each string can contain one or more language codes, separated by commas. WDQS considers languages in the order in which you specify them. If no label is available in any of the specified languages, the Q-id of the entity (without any prefix) is its label. </p><p>The Wikidata Query Service website automatically replaces <code>[AUTO_LANGUAGE]</code> with the language code of current user's interface. For example, if the user's UI is in French, the SPARQL's code <code class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"[AUTO_LANGUAGE],en"</span></code> will be converted to <code class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"fr,en"</span></code> before being sent to the query service. </p><p>Example, showing the list of US presidents and their spouses: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span> <span class="nv">?p</span> <span class="nv">?pLabel</span> <span class="nv">?w</span> <span class="nv">?wLabel</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q30</span> <span class="nn">p</span><span class="p">:</span><span class="nt">P6</span><span class="o">/</span><span class="nn">ps</span><span class="p">:</span><span class="nt">P6</span> <span class="nv">?p</span> <span class="p">.</span> <span class="nv">?p</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P26</span> <span class="nv">?w</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"en"</span> <span class="p">.</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#SELECT%20%3Fp%20%3FpLabel%20%3Fw%20%3FwLabel%20WHERE%20%7B%0A%20%20%20wd%3AQ30%20p%3AP6%2Fps%3AP6%20%3Fp%20.%0A%20%20%20%3Fp%20wdt%3AP26%20%3Fw%20.%0A%20%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%0A%20%20%20%7D%0A%20%7D">Try it!</a> </p><p>In this example WDQS automatically creates the labels <code>?pLabel</code> and <code>?wLabel</code> for properties. </p><p>In the manual mode, you explicitly bind the label variables within the service call, but WDQS will still provide language resolution and fallback. Example: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span> <span class="k">SELECT</span> <span class="o">*</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"fr,de,en"</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q123</span> <span class="nn">rdfs</span><span class="p">:</span><span class="nt">label</span> <span class="nv">?q123Label</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q123</span> <span class="nn">skos</span><span class="p">:</span><span class="nt">altLabel</span> <span class="nv">?q123Alt</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q123</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">description</span> <span class="nv">?q123Desc</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q321</span> <span class="nn">rdf</span><span class="p">:</span><span class="nt">label</span> <span class="nv">?q321Label</span> <span class="p">.</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p>This will consider labels and descriptions in French, German and English, and if none are available, will use the Q-id as the label. </p> <div class="mw-heading mw-heading3"><h3 id="Geospatial_search" data-mw-thread-id="h-Geospatial_search-Extensions"><span data-mw-comment-start="" id="h-Geospatial_search-Extensions"></span>Geospatial search<span data-mw-comment-end="h-Geospatial_search-Extensions"></span></h3></div> <p>The service allows to search for items with coordinates located within a certain radius of a central point or within a certain bounding box. </p> <div class="mw-heading mw-heading4"><h4 id="Search_around_point" data-mw-thread-id="h-Search_around_point-Geospatial_search"><span data-mw-comment-start="" id="h-Search_around_point-Geospatial_search"></span>Search around point<span data-mw-comment-end="h-Search_around_point-Geospatial_search"></span></h4></div> <p>Example: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Airports within 100km from Berlin</span> <span class="c">#defaultView:Map</span> <span class="k">SELECT</span> <span class="nv">?place</span> <span class="nv">?placeLabel</span> <span class="nv">?location</span> <span class="nv">?dist</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="c"># Berlin coordinates</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q64</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?berlinLoc</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">around</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">center</span> <span class="nv">?berlinLoc</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">radius</span> <span class="s">"100"</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">distance</span> <span class="nv">?dist</span><span class="p">.</span> <span class="p">}</span> <span class="c"># Is an airport</span> <span class="k">FILTER</span> <span class="nf">EXISTS</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span><span class="o">/</span><span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span><span class="o">*</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q1248784</span> <span class="p">}</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"en"</span> <span class="p">.</span> <span class="p">}</span> <span class="p">}</span> <span class="k">ORDER BY</span> <span class="k">ASC</span><span class="p">(</span><span class="nv">?dist</span><span class="p">)</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23%20Airports%20within%20100km%20from%20Berlin%0A%23defaultView%3AMap%0ASELECT%20%3Fplace%20%3FplaceLabel%20%3Flocation%20%3Fdist%20WHERE%20%7B%0A%20%20%23%20Berlin%20coordinates%0A%20%20wd%3AQ64%20wdt%3AP625%20%3FberlinLoc%20.%20%0A%20%20SERVICE%20wikibase%3Aaround%20%7B%20%0A%20%20%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Acenter%20%3FberlinLoc%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aradius%20%22100%22%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Adistance%20%3Fdist.%0A%20%20%7D%20%0A%20%20%23%20Is%20an%20airport%0A%20%20FILTER%20EXISTS%20%7B%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ1248784%20%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%20%0A%20%20%7D%0A%7D%20ORDER%20BY%20ASC%28%3Fdist%29">Try it!</a> </p><p>The first line of the <code>around</code> service call must have format <code>?item</code> <code>predicate</code> <code>?location</code>, where the result of the search will bind <code>?item</code> to items within the specified location and <code>?location</code> to their coordinates. The parameters supported are: </p> <table class="wikitable"> <tbody><tr> <th>Predicate </th> <th>Meaning </th></tr> <tr> <td>wikibase:center </td> <td>The point around which search is performed. Must be bound for search to work. </td></tr> <tr> <td>wikibase:radius </td> <td>Distance from the center. Currently the distance is always in kilometers, other units are not supported yet. </td></tr> <tr> <td>wikibase:globe </td> <td>The globe which is being searched. Optional, default is <a class="external text" href="https://www.wikidata.org/wiki/Q2">Earth (wd:Q2)</a>. </td></tr> <tr> <td>wikibase:distance </td> <td>The variable receiving distance information </td></tr></tbody></table> <div class="mw-heading mw-heading4"><h4 id="Search_within_box" data-mw-thread-id="h-Search_within_box-Geospatial_search"><span data-mw-comment-start="" id="h-Search_within_box-Geospatial_search"></span>Search within box<span data-mw-comment-end="h-Search_within_box-Geospatial_search"></span></h4></div> <p>Example of box search: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Schools between San Jose, CA and Sacramento, CA</span> <span class="c">#defaultView:Map</span> <span class="k">SELECT</span> <span class="o">*</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q16553</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?SJloc</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q18013</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?SCloc</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">box</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerSouthWest</span> <span class="nv">?SJloc</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerNorthEast</span> <span class="nv">?SCloc</span> <span class="p">.</span> <span class="p">}</span> <span class="k">FILTER</span> <span class="nf">EXISTS</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span><span class="o">/</span><span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span><span class="o">*</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q3914</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23%20Schools%20between%20San%20Jose%2C%20CA%20and%20Sacramento%2C%20CA%0A%23defaultView%3AMap%0ASELECT%20%2A%20WHERE%20%7B%0A%20%20wd%3AQ16553%20wdt%3AP625%20%3FSJloc%20.%0A%20%20wd%3AQ18013%20wdt%3AP625%20%3FSCloc%20.%0A%20%20SERVICE%20wikibase%3Abox%20%7B%0A%20%20%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerSouthWest%20%3FSJloc%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerNorthEast%20%3FSCloc%20.%0A%20%20%7D%0A%20%20FILTER%20EXISTS%20%7B%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ3914%20%7D%0A%7D">Try it!</a> </p><p>or: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c">#Schools between San Jose, CA and San Francisco, CA</span> <span class="c">#defaultView:Map</span> <span class="k">SELECT</span> <span class="nv">?place</span> <span class="nv">?location</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q62</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?SFloc</span> <span class="p">.</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q16553</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?SJloc</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">box</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerWest</span> <span class="nv">?SFloc</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerEast</span> <span class="nv">?SJloc</span> <span class="p">.</span> <span class="p">}</span> <span class="k">FILTER</span> <span class="nf">EXISTS</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span><span class="o">/</span><span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span><span class="o">*</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q3914</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23Schools%20between%20San%20Jose%2C%20CA%20and%20San%20Francisco%2C%20CA%0A%23defaultView%3AMap%0ASELECT%20%3Fplace%20%3Flocation%20WHERE%20%7B%0A%20%20wd%3AQ62%20wdt%3AP625%20%3FSFloc%20.%0A%20%20wd%3AQ16553%20wdt%3AP625%20%3FSJloc%20.%0A%20%20SERVICE%20wikibase%3Abox%20%7B%0A%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%0A%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerWest%20%3FSFloc%20.%0A%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerEast%20%3FSJloc%20.%0A%20%20%7D%0A%20%20FILTER%20EXISTS%20%7B%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ3914%20%7D%0A%7D">Try it!</a> </p><p>Coordinates may be specified directly: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Schools between San Jose, CA and Sacramento, CA</span> <span class="c">#same as previous</span> <span class="c">#defaultView:Map</span> <span class="k">SELECT</span> <span class="o">*</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">box</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerWest</span> <span class="s">"Point(-121.872777777 37.304166666)"</span><span class="o">^^</span><span class="nn">geo</span><span class="p">:</span><span class="nt">wktLiteral</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">cornerEast</span> <span class="s">"Point(-121.486111111 38.575277777)"</span><span class="o">^^</span><span class="nn">geo</span><span class="p">:</span><span class="nt">wktLiteral</span> <span class="p">.</span> <span class="p">}</span> <span class="k">FILTER</span> <span class="nf">EXISTS</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span><span class="o">/</span><span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span><span class="o">*</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q3914</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23%20Schools%20between%20San%20Jose%2C%20CA%20and%20Sacramento%2C%20CA%0A%23same%20as%20previous%0A%23defaultView%3AMap%0ASELECT%20%2A%20WHERE%20%7B%0ASERVICE%20wikibase%3Abox%20%7B%0A%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%0A%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerWest%20%22Point%28-121.872777777%2037.304166666%29%22%5E%5Egeo%3AwktLiteral%20.%0A%20%20%20%20bd%3AserviceParam%20wikibase%3AcornerEast%20%22Point%28-121.486111111%2038.575277777%29%22%5E%5Egeo%3AwktLiteral%20.%0A%20%20%7D%0A%20%20FILTER%20EXISTS%20%7B%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ3914%20%7D%0A%7D">Try it!</a> </p><p>The first line of the <code>box</code> service call must have format <code>?item</code> <code>predicate</code> <code>?location</code>, where and the result of the search will bind <code>?item</code> to items within the specified location and <code>?location</code> to their coordinates. The parameters supported are: </p> <table class="wikitable"> <tbody><tr> <th>Predicate </th> <th>Meaning </th></tr> <tr> <td>wikibase:cornerSouthWest </td> <td>The south-west corner of the box. </td></tr> <tr> <td>wikibase:cornerNorthEast </td> <td>The north-east corner of the box. </td></tr> <tr> <td>wikibase:cornerWest </td> <td>The western corner of the box. </td></tr> <tr> <td>wikibase:cornerEast </td> <td>The eastern corner of the box. </td></tr> <tr> <td>wikibase:globe </td> <td>The globe which is being searched. Optional, default is <a class="external text" href="https://www.wikidata.org/wiki/Q2">Earth (wd:Q2)</a>. </td></tr></tbody></table> <p><code>wikibase:cornerSouthWest</code> and <code>wikibase:cornerNorthEast</code> should be used together, as well as <code>wikibase:cornerWest</code> and <code>wikibase:cornerEast</code>, and cannot be mixed. If <code>wikibase:cornerWest</code> and <code>wikibase:cornerEast</code> predicates are used, then the points are assumed to be the coordinates of the diagonal of the box, and the corners are derived accordingly. </p> <div class="mw-heading mw-heading3"><h3 id="Extended_functions" data-mw-thread-id="h-Extended_functions-Extensions"><span data-mw-comment-start="" id="h-Extended_functions-Extensions"></span>Extended functions<span data-mw-comment-end="h-Extended_functions-Extensions"></span></h3></div> <div class="mw-heading mw-heading4"><h4 id="Distance_function" data-mw-thread-id="h-Distance_function-Extended_functions"><span data-mw-comment-start="" id="h-Distance_function-Extended_functions"></span>Distance function<span data-mw-comment-end="h-Distance_function-Extended_functions"></span></h4></div> <p>The function <code>geof:distance</code> returns distance between two points on Earth, in kilometers. Example usage: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Airports within 100km from Berlin</span> <span class="k">SELECT</span> <span class="nv">?place</span> <span class="nv">?placeLabel</span> <span class="nv">?location</span> <span class="nv">?dist</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="c"># Berlin coordinates</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q64</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?berlinLoc</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">around</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">center</span> <span class="nv">?berlinLoc</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">radius</span> <span class="s">"100"</span> <span class="p">.</span> <span class="p">}</span> <span class="c"># Is an airport</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span><span class="o">/</span><span class="nn">wdt</span><span class="p">:</span><span class="nt">P279</span><span class="o">*</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q1248784</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"en"</span> <span class="p">.</span> <span class="p">}</span> <span class="k">BIND</span><span class="p">(</span><span class="nn">geof</span><span class="p">:</span><span class="nt">distance</span><span class="p">(</span><span class="nv">?berlinLoc</span><span class="p">,</span> <span class="nv">?location</span><span class="p">)</span> <span class="k">as</span> <span class="nv">?dist</span><span class="p">)</span> <span class="p">}</span> <span class="k">ORDER BY</span> <span class="nv">?dist</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23%20Airports%20within%20100km%20from%20Berlin%0ASELECT%20%3Fplace%20%3FplaceLabel%20%3Flocation%20%3Fdist%20WHERE%20%7B%0A%0A%20%20%23%20Berlin%20coordinates%0A%20%20wd%3AQ64%20wdt%3AP625%20%3FberlinLoc%20.%20%0A%20%20SERVICE%20wikibase%3Aaround%20%7B%20%0A%20%20%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Acenter%20%3FberlinLoc%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aradius%20%22100%22%20.%20%0A%20%20%7D%20%0A%20%20%23%20Is%20an%20airport%0A%20%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ1248784%20.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%20%0A%20%20%7D%0A%20%20BIND%28geof%3Adistance%28%3FberlinLoc%2C%20%3Flocation%29%20as%20%3Fdist%29%20%0A%7D%20ORDER%20BY%20%3Fdist">Try it!</a> </p><div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Places around 0°,0° </span> <span class="k">SELECT</span> <span class="o">*</span> <span class="p">{</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">around</span> <span class="p">{</span> <span class="nv">?place</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P625</span> <span class="nv">?location</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">center</span> <span class="s">"Point(0 0)"</span><span class="o">^^</span><span class="nn">geo</span><span class="p">:</span><span class="nt">wktLiteral</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">radius</span> <span class="s">"250"</span> <span class="p">.</span> <span class="p">}</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">label</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">language</span> <span class="s">"en"</span> <span class="p">.</span> <span class="nv">?place</span> <span class="nn">rdfs</span><span class="p">:</span><span class="nt">label</span> <span class="nv">?placeLabel</span> <span class="p">}</span> <span class="k">BIND</span><span class="p">(</span><span class="nn">geof</span><span class="p">:</span><span class="nt">distance</span><span class="p">(</span><span class="s">"Point(0 0)"</span><span class="o">^^</span><span class="nn">geo</span><span class="p">:</span><span class="nt">wktLiteral</span><span class="p">,</span> <span class="nv">?location</span><span class="p">)</span> <span class="k">as</span> <span class="nv">?dist</span><span class="p">)</span> <span class="p">}</span> <span class="k">ORDER BY</span> <span class="nv">?dist</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#%23%20Places%20around%200%C2%B0%2C0%C2%B0%20%0ASELECT%20%2A%0A%7B%0A%20%20SERVICE%20wikibase%3Aaround%20%7B%20%0A%20%20%20%20%20%20%3Fplace%20wdt%3AP625%20%3Flocation%20.%20%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Acenter%20%22Point%280%200%29%22%5E%5Egeo%3AwktLiteral%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aradius%20%22250%22%20.%20%0A%20%20%7D%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%20%3Fplace%20rdfs%3Alabel%20%3FplaceLabel%20%7D%0A%20%20BIND%28geof%3Adistance%28%22Point%280%200%29%22%5E%5Egeo%3AwktLiteral%2C%20%3Flocation%29%20as%20%3Fdist%29%20%0A%7D%20%0AORDER%20BY%20%3Fdist">Try it!</a> </p><div class="mw-heading mw-heading4"><h4 id="Coordinate_parts_functions" data-mw-thread-id="h-Coordinate_parts_functions-Extended_functions"><span data-mw-comment-start="" id="h-Coordinate_parts_functions-Extended_functions"></span>Coordinate parts functions<span data-mw-comment-end="h-Coordinate_parts_functions-Extended_functions"></span></h4></div> <p>Functions <code>geof:globe</code>, <code>geof:latitude</code> & <code>geof:longitude</code> return parts of a coordinate - globe URI, latitude and longitude accordingly. </p> <div class="mw-heading mw-heading4"><h4 id="Decode_URL_functions" data-mw-thread-id="h-Decode_URL_functions-Extended_functions"><span data-mw-comment-start="" id="h-Decode_URL_functions-Extended_functions"></span>Decode URL functions<span data-mw-comment-end="h-Decode_URL_functions-Extended_functions"></span></h4></div> <p>Function <code>wikibase:decodeUri</code> decodes (i.e. reverses <a href="https://en.wikipedia.org/wiki/Percent-encoding" class="extiw" title="w:Percent-encoding">percent-encoding</a>) given URI string. This may be necessary when converting Wikipedia titles (which are encoded) into actual strings. This function is an opposite of SPARQL <a rel="nofollow" class="external text" href="https://www.w3.org/TR/sparql11-query/#func-encode">encode_for_uri</a> function. </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="c"># Example usage of wikibase:decodeUri function</span> <span class="k">SELECT</span> <span class="k">DISTINCT</span> <span class="o">*</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nv">?el</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P31</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q5</span><span class="p">.</span> <span class="nv">?webRaw</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">about</span> <span class="nv">?el</span><span class="p">;</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">inLanguage</span> <span class="s">"ru"</span><span class="p">;</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">isPartOf</span> <span class="nl"><https://ru.wikipedia.org/></span><span class="p">.</span> <span class="k">BIND</span><span class="p">(</span><span class="nf">URI</span><span class="p">(</span><span class="nn">wikibase</span><span class="p">:</span><span class="nt">decodeUri</span><span class="p">(</span><span class="nf">STR</span><span class="p">(</span><span class="nv">?webRaw</span><span class="p">)))</span> <span class="k">AS</span> <span class="nv">?webHyperlink</span><span class="p">)</span> <span class="p">.</span> <span class="k">BIND</span><span class="p">(</span><span class="nn">wikibase</span><span class="p">:</span><span class="nt">decodeUri</span><span class="p">(</span><span class="nf">STR</span><span class="p">(</span><span class="nv">?webRaw</span><span class="p">))</span> <span class="k">AS</span> <span class="nv">?webString</span><span class="p">)</span> <span class="p">.</span> <span class="p">}</span> <span class="k">LIMIT</span> <span class="mi">20</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Automatic_prefixes" data-mw-thread-id="h-Automatic_prefixes-Extensions"><span data-mw-comment-start="" id="h-Automatic_prefixes-Extensions"></span>Automatic prefixes<span data-mw-comment-end="h-Automatic_prefixes-Extensions"></span></h3></div> <p>Most <a href="/wiki/Special:MyLanguage/Wikibase/Indexing/RDF_Dump_Format" title="Special:MyLanguage/Wikibase/Indexing/RDF Dump Format">prefixes</a> that are used in common queries are supported by the engine without the need to explicitly specify them. </p> <div class="mw-heading mw-heading3"><h3 id="Extended_dates" data-mw-thread-id="h-Extended_dates-Extensions"><span data-mw-comment-start="" id="h-Extended_dates-Extensions"></span>Extended dates<span data-mw-comment-end="h-Extended_dates-Extensions"></span></h3></div> <p>The service supports date values of type <code>xsd:dateTime</code> in the range of about 290B years in the past and in the future, with one-second resolution. WDQS stores dates as the 64-bit number of seconds since the Unix epoch. </p> <div class="mw-heading mw-heading3"><h3 id="Blazegraph_extensions" data-mw-thread-id="h-Blazegraph_extensions-Extensions"><span data-mw-comment-start="" id="h-Blazegraph_extensions-Extensions"></span>Blazegraph extensions<span data-mw-comment-end="h-Blazegraph_extensions-Extensions"></span></h3></div> <table class="warning-message" style="background-color: var( --background-color-error-subtle, #ffe9e5 ); color: var( --color-base, #202122 ); border: 1px var( --border-color-error, #9f3526 ) solid; box-sizing: border-box; margin: 0.5em 0; padding: 0.5em;"><tbody><tr><td style="white-space: nowrap; vertical-align: top;"><span style="position: relative; top: -2px;"><span typeof="mw:File"><span><img alt="Warning" src="//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/18px-OOjs_UI_icon_notice-destructive.svg.png" decoding="async" width="18" height="18" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/27px-OOjs_UI_icon_notice-destructive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/36px-OOjs_UI_icon_notice-destructive.svg.png 2x" data-file-width="20" data-file-height="20"/></span></span></span> <b>Warning:</b> </td><td style="padding-left: 0.5em vertical-align: top;">As Blazegraph is not actively developed, it is planned to migrate Wikidata Query Service to another triplestore. The following may be discontinued at some point.</td></tr></tbody></table> <p><a rel="nofollow" class="external text" href="https://wiki.blazegraph.com/wiki/index.php/About_Blazegraph">Blazegraph</a> platform on top of which WDQS is implemented has its own set of SPARQL extension. Among them several graph traversal algorithms which are <a rel="nofollow" class="external text" href="https://github.com/blazegraph/database/wiki/RDF_GAS_API">documented on Blazegraph Wiki</a>, including BFS, shortest path, CC and PageRank implementations. </p><p>Please also refer to the Blazegraph <a rel="nofollow" class="external text" href="https://github.com/blazegraph/database/wiki/QueryOptimization">documentation on query hints</a> for information about how to control query execution and various aspects of the engine. </p><p>There is no documentation in the BlazeGraph wiki about the bd:sample extension. It's documented only <a rel="nofollow" class="external text" href="https://github.com/blazegraph/database/blob/3127706f0b6504838daae226b9158840d2df1744/bigdata-core/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/SampleServiceFactory.java">in a comment in the code</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Federation" data-mw-thread-id="h-Federation-Extensions"><span data-mw-comment-start="" id="h-Federation-Extensions"></span>Federation<span data-mw-comment-end="h-Federation-Extensions"></span></h3></div> <p>We allow <a rel="nofollow" class="external text" href="https://www.w3.org/TR/sparql11-federated-query/">SPARQL Federated Queries</a> to call out to a selected number of external databases. Please see <a href="/wiki/Special:MyLanguage/Wikidata_Query_Service/User_Manual/SPARQL_Federation_endpoints" title="Special:MyLanguage/Wikidata Query Service/User Manual/SPARQL Federation endpoints">the full list of federated endpoints</a> on the dedicated page. </p><p>Example federated query: </p><p><br/> </p> <ul><li>Items used: <a class="external text" href="https://www.wikidata.org/wiki/Q165257">Lope de Vega (Q165257)</a></li></ul> <ul><li>Properties used: <a class="external text" href="https://www.wikidata.org/wiki/Property:P2799">BVMC person ID (P2799)</a></li></ul> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span> <span class="nv">?workLabel</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q165257</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P2799</span> <span class="nv">?id</span> <span class="k">BIND</span><span class="p">(</span><span class="nf">uri</span><span class="p">(</span><span class="nf">concat</span><span class="p">(</span><span class="s">"https://data.cervantesvirtual.com/person/"</span><span class="p">,</span> <span class="nv">?id</span><span class="p">))</span> <span class="k">as</span> <span class="nv">?bvmcID</span><span class="p">)</span> <span class="k">SERVICE</span> <span class="nl"><http://data.cervantesvirtual.com/openrdf-sesame/repositories/data></span> <span class="p">{</span> <span class="nv">?bvmcID</span> <span class="nl"><http://rdaregistry.info/Elements/a/otherPFCManifestationOf></span> <span class="nv">?work</span> <span class="p">.</span> <span class="nv">?work</span> <span class="nn">rdfs</span><span class="p">:</span><span class="nt">label</span> <span class="nv">?workLabel</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#SELECT%20%3FworkLabel%20WHERE%20%7B%0A%20%20wd%3AQ165257%20wdt%3AP2799%20%3Fid%20%0A%20%20BIND%28uri%28concat%28%22https%3A%2F%2Fdata.cervantesvirtual.com%2Fperson%2F%22%2C%20%3Fid%29%29%20as%20%3FbvmcID%29%20%0A%20%20SERVICE%20%3Chttp%3A%2F%2Fdata.cervantesvirtual.com%2Fopenrdf-sesame%2Frepositories%2Fdata%3E%20%7B%0A%20%20%20%20%3FbvmcID%20%3Chttp%3A%2F%2Frdaregistry.info%2FElements%2Fa%2FotherPFCManifestationOf%3E%20%3Fwork%20.%0A%20%20%20%20%3Fwork%20rdfs%3Alabel%20%3FworkLabel%20%20%20%20%20%20%20%20%0A%20%20%7D%0A%7D">Try it!</a> </p><p>Please note that the databases that the federated endpoints serve use ontologies that may be very different from the Wikidata one. Please refer to the <a href="/wiki/Special:MyLanguage/Wikidata_Query_Service/User_Manual/SPARQL_Federation_endpoints" title="Special:MyLanguage/Wikidata Query Service/User Manual/SPARQL Federation endpoints">owner documentation links</a> to learn about the ontologies and data access to these databases. </p> <div class="mw-heading mw-heading3"><h3 id="MediaWiki_API" data-mw-thread-id="h-MediaWiki_API-Extensions"><span data-mw-comment-start="" id="h-MediaWiki_API-Extensions"></span>MediaWiki API<span data-mw-comment-end="h-MediaWiki_API-Extensions"></span></h3></div> <p><i>Please see full description on <a href="/wiki/Wikidata_query_service/User_Manual/MWAPI" class="mw-redirect" title="Wikidata query service/User Manual/MWAPI">MediaWiki API Service documentation page</a>.</i> </p><p>MediaWiki API Service allows to call out to MediaWiki API from SPARQL, and receive the results from inside the SPARQL query. Example (finding category members): </p><p><br/> </p> <ul><li>Items used: <a class="external text" href="https://www.wikidata.org/wiki/Q6501349">parking lot (Q6501349)</a></li></ul> <ul><li>Properties used: <a class="external text" href="https://www.wikidata.org/wiki/Property:P910">topic's main category (P910)</a></li></ul> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">SELECT</span> <span class="o">*</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nn">wd</span><span class="p">:</span><span class="nt">Q6501349</span> <span class="nn">wdt</span><span class="p">:</span><span class="nt">P910</span> <span class="nv">?category</span> <span class="p">.</span> <span class="nv">?link</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">about</span> <span class="nv">?category</span><span class="p">;</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">isPartOf</span> <span class="nl"><https://en.wikipedia.org/></span><span class="p">;</span> <span class="nn">schema</span><span class="p">:</span><span class="nt">name</span> <span class="nv">?title</span> <span class="p">.</span> <span class="k">SERVICE</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">mwapi</span> <span class="p">{</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">api</span> <span class="s">"Generator"</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">endpoint</span> <span class="s">"en.wikipedia.org"</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">gcmtitle</span> <span class="nv">?title</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">generator</span> <span class="s">"categorymembers"</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">gcmprop</span> <span class="s">"ids|title|type"</span> <span class="p">.</span> <span class="nn">bd</span><span class="p">:</span><span class="nt">serviceParam</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">gcmlimit</span> <span class="s">"max"</span> <span class="p">.</span> <span class="c"># out</span> <span class="nv">?subcat</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">apiOutput</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">title</span> <span class="p">.</span> <span class="nv">?ns</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">apiOutput</span> <span class="s">"@ns"</span> <span class="p">.</span> <span class="nv">?item</span> <span class="nn">wikibase</span><span class="p">:</span><span class="nt">apiOutputItem</span> <span class="nn">mwapi</span><span class="p">:</span><span class="nt">item</span> <span class="p">.</span> <span class="p">}</span> <span class="p">}</span> </pre></div> <p><a class="external text" href="https://query.wikidata.org/#SELECT%20%2A%20WHERE%20%7B%0A%20%20wd%3AQ6501349%20wdt%3AP910%20%3Fcategory%20.%0A%20%20%3Flink%20schema%3Aabout%20%3Fcategory%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wikipedia.org%2F%3E%3B%20schema%3Aname%20%3Ftitle%20.%0A%20%20SERVICE%20wikibase%3Amwapi%20%7B%0A%09%20bd%3AserviceParam%20wikibase%3Aapi%20%22Generator%22%20.%0A%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aendpoint%20%22en.wikipedia.org%22%20.%0A%20%20%20%20%20bd%3AserviceParam%20mwapi%3Agcmtitle%20%3Ftitle%20.%0A%20%20%20%20%20bd%3AserviceParam%20mwapi%3Agenerator%20%22categorymembers%22%20.%0A%20%20%20%20%20bd%3AserviceParam%20mwapi%3Agcmprop%20%22ids%7Ctitle%7Ctype%22%20.%0A%20%20%20%20%20bd%3AserviceParam%20mwapi%3Agcmlimit%20%22max%22%20.%0A%20%20%20%20%23%20out%0A%20%20%20%20%3Fsubcat%20wikibase%3AapiOutput%20mwapi%3Atitle%20%20.%0A%20%20%20%20%3Fns%20wikibase%3AapiOutput%20%22%40ns%22%20.%0A%20%20%20%20%3Fitem%20wikibase%3AapiOutputItem%20mwapi%3Aitem%20.%0A%20%20%7D%0A%7D">Try it!</a> </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Wikimedia_service" data-mw-thread-id="h-Wikimedia_service"><span data-mw-comment-start="" id="h-Wikimedia_service"></span>Wikimedia service<span data-mw-comment-end="h-Wikimedia_service"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikimedia_service","replies":["h-GUI-Wikimedia_service","h-SPARQL_endpoint-Wikimedia_service","h-Namespaces-Wikimedia_service","h-Linked_Data_Fragments_endpoint-Wikimedia_service"]}}--></div> <p>Wikimedia runs the public service instance of WDQS, which is available for use at <a class="external free" href="https://query.wikidata.org/">http://query.wikidata.org/</a>. </p><p>The runtime of the query on the public endpoint is limited to 60 seconds. That is true both for the GUI and the public SPARQL endpoint. </p> <div class="mw-heading mw-heading3"><h3 id="GUI" data-mw-thread-id="h-GUI-Wikimedia_service"><span data-mw-comment-start="" id="h-GUI-Wikimedia_service"></span>GUI<span data-mw-comment-end="h-GUI-Wikimedia_service"></span></h3></div> <p>The GUI at the home page of <a class="external free" href="https://query.wikidata.org/">http://query.wikidata.org/</a> allows you to edit and submit SPARQL queries to the query engine. The results are displayed as an HTML table. Note that every query has a unique URL which can be bookmarked for later use. Going to this URL will put the query in the edit window, but will <b>not</b> run it - you still have to click "Execute" for that. </p><p>One can also generate a short URL for the query via a URL shortening service by clicking the "Generate short URL" link on the right - this will produce the shortened URL for the current query. </p><p>The "Add prefixes" button generates the header containing standard prefixes for SPARQL queries. The full list of prefixes that can be useful is listed in the <a href="/wiki/Wikibase/Indexing/RDF_Dump_Format#Full_list_of_prefixes" title="Wikibase/Indexing/RDF Dump Format">RDF format documentation</a>. Note that most common prefixes work automatically, since WDQS supports them out of the box. </p><p>The GUI also features a simple entity explorer which can be activated by clicking on the "🔍" symbol next to the entity result. Clicking on the entity Q-id itself will take you to the entity page on wikidata.org. </p> <div class="mw-heading mw-heading4"><h4 id="Default_views" data-mw-thread-id="h-Default_views-GUI"><span data-mw-comment-start="" id="h-Default_views-GUI"></span>Default views<span data-mw-comment-end="h-Default_views-GUI"></span></h4></div> <dl><dd><i>Main article: <a href="https://www.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_query_service/Wikidata_Query_Help/Result_Views" class="extiw" title="wikidata:Special:MyLanguage/Wikidata:SPARQL query service/Wikidata Query Help/Result Views">Wikidata:SPARQL query service/Wikidata Query Help/Result Views</a></i></dd></dl> <p>If you run the query in the WDQS GUI, you can choose which view to present by specifying the tag: <code>#defaultView:viewName</code> at the beginning of the query. </p> <div class="mw-heading mw-heading4"><h4 id="Display_a_title" data-mw-thread-id="h-Display_a_title-GUI"><span data-mw-comment-start="" id="h-Display_a_title-GUI"></span>Display a title<span data-mw-comment-end="h-Display_a_title-GUI"></span></h4></div> <p>If you run the query in the WDQS GUI, you can display a title on top of the results by specifying the tag: <code>#title: String you want to display</code> at the beginning of the query. </p> <div class="mw-heading mw-heading3"><h3 id="SPARQL_endpoint" data-mw-thread-id="h-SPARQL_endpoint-Wikimedia_service"><span data-mw-comment-start="" id="h-SPARQL_endpoint-Wikimedia_service"></span>SPARQL endpoint<span data-mw-comment-end="h-SPARQL_endpoint-Wikimedia_service"></span></h3></div> <p>SPARQL queries can be submitted directly to the SPARQL endpoint with a GET or POST request to <code><a class="external free" href="https://query.wikidata.org/sparql">https://query.wikidata.org/sparql</a></code>. </p><p>GET requests have the query specified in the URL, in the format <code><a class="external free" href="https://query.wikidata.org/sparql?query=(SPARQL_query)">https://query.wikidata.org/sparql?query=(SPARQL_query)</a></code>, e.g. <code><a class="external free" href="https://query.wikidata.org/sparql?query=SELECT%20?dob%20WHERE%20{wd:Q42%20wdt:P569%20?dob.}">https://query.wikidata.org/sparql?query=SELECT%20?dob%20WHERE%20{wd:Q42%20wdt:P569%20?dob.}</a></code>. </p><p>POST requests can alternatively accept the query in the body of the request, instead of the URL, which allows running larger queries without hitting URL length limits. (Note that the POST body must still include the <code>query=</code> prefix (that is, it should be <code>query=(SPARQL_query)</code> rather than just <code>(SPARQL query)</code>), and the SPARQL query must still be URL-escaped.) </p><p>The result is returned as XML by default, or as JSON if either the query parameter <code>format=json</code> is included in the URL, or the header <code>Accept: application/sparql-results+json</code> is provided with the request. </p><p>The JSON format is standard <a rel="nofollow" class="external text" href="https://www.w3.org/TR/sparql11-results-json/">SPARQL 1.1 Query Results JSON Format</a>. </p><p>It is recommended to use GET for smaller queries and POST for larger queries, as POST queries are not cached. </p> <div class="mw-heading mw-heading4"><h4 id="Supported_formats" data-mw-thread-id="h-Supported_formats-SPARQL_endpoint"><span data-mw-comment-start="" id="h-Supported_formats-SPARQL_endpoint"></span>Supported formats<span data-mw-comment-end="h-Supported_formats-SPARQL_endpoint"></span></h4></div> <p>The following output formats are currently supported by the SPARQL endpoint: </p> <table class="wikitable"> <tbody><tr> <th>Format </th> <th>HTTP Header </th> <th>Query parameter </th> <th>Description </th></tr> <tr> <td>XML </td> <td>Accept: application/sparql-results+xml </td> <td>format=xml </td> <td>XML result format, is returned by default. As specified in <a rel="nofollow" class="external free" href="https://www.w3.org/TR/rdf-sparql-XMLres/">https://www.w3.org/TR/rdf-sparql-XMLres/</a> </td></tr> <tr> <td>JSON </td> <td>Accept: application/sparql-results+json </td> <td>format=json </td> <td>JSON result format, as in: <a rel="nofollow" class="external free" href="https://www.w3.org/TR/sparql11-results-json/">https://www.w3.org/TR/sparql11-results-json/</a> </td></tr> <tr> <td>TSV </td> <td>Accept: text/tab-separated-values </td> <td> </td> <td>As specified in <a rel="nofollow" class="external free" href="https://www.w3.org/TR/sparql11-results-csv-tsv/">https://www.w3.org/TR/sparql11-results-csv-tsv/</a> </td></tr> <tr> <td>CSV </td> <td>Accept: text/csv </td> <td> </td> <td>As specified in <a rel="nofollow" class="external free" href="https://www.w3.org/TR/sparql11-results-csv-tsv/">https://www.w3.org/TR/sparql11-results-csv-tsv/</a> </td></tr> <tr> <td>Binary RDF </td> <td>Accept: application/x-binary-rdf-results-table </td> <td> </td> <td> </td></tr></tbody></table> <div class="mw-heading mw-heading4"><h4 id="Query_limits" data-mw-thread-id="h-Query_limits-SPARQL_endpoint"><span data-mw-comment-start="" id="h-Query_limits-SPARQL_endpoint"></span>Query limits<span data-mw-comment-end="h-Query_limits-SPARQL_endpoint"></span></h4></div> <p>There is a hard query deadline configured which is set to <b>60 seconds</b>. There are also following limits: </p> <ul><li>One client (user agent + IP) is allowed 60 seconds of processing time each 60 seconds</li> <li>One client is allowed 30 error queries per minute</li></ul> <p>Clients exceeding the limits above are throttled with HTTP code <code>429</code>. Use <code>Retry-After</code> <a href="https://en.wikipedia.org/wiki/List_of_HTTP_header_fields" class="extiw" title="w:List of HTTP header fields">header</a> to see when the request can be repeated. If the client ignores 429 responses and continues to produce requests over the limits, it can be temporarily banned from the service. Clients who don’t comply with the <a href="https://meta.wikimedia.org/wiki/Special:MyLanguage/User-Agent_policy" class="extiw" title="m:Special:MyLanguage/User-Agent policy">User-Agent policy</a> may be blocked completely – make sure to send a good <code>User-Agent</code> <a href="https://en.wikipedia.org/wiki/List_of_HTTP_header_fields" class="extiw" title="w:List of HTTP header fields">header</a>. </p><p>Every query will timeout when it takes more time to execute than this configured deadline. You may want to <a href="https://www.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_query_service/query_optimization" class="extiw" title="d:Special:MyLanguage/Wikidata:SPARQL query service/query optimization">optimize the query</a> or report a problematic query <a href="/wiki/Special:MyLanguage/Wikidata_Query_Service/Problematic_queries" title="Special:MyLanguage/Wikidata Query Service/Problematic queries">here</a>. </p><p>Also note that currently access to the service is limited to 5 parallel queries per IP. The above limits are subject to change depending on resources and usage patterns. </p> <div class="mw-heading mw-heading4"><h4 id="Explain_Query" data-mw-thread-id="h-Explain_Query-SPARQL_endpoint"><span data-mw-comment-start="" id="h-Explain_Query-SPARQL_endpoint"></span>Explain Query<span data-mw-comment-end="h-Explain_Query-SPARQL_endpoint"></span></h4></div> <p>Blazegraph allows to show query analysis that explains how the query has been parsed and which optimizations were applied. To see this information, add <code>explain=details</code> parameter to the query string, for example: <code><a class="external free" href="https://query.wikidata.org/sparql?query=SELECT%20?dob%20WHERE%20{wd:Q42%20wdt:P569%20?dob.}&explain=details">https://query.wikidata.org/sparql?query=SELECT%20?dob%20WHERE%20{wd:Q42%20wdt:P569%20?dob.}&explain=details</a></code>. </p> <div class="mw-heading mw-heading3"><h3 id="Namespaces" data-mw-thread-id="h-Namespaces-Wikimedia_service"><span data-mw-comment-start="" id="h-Namespaces-Wikimedia_service"></span>Namespaces<span data-mw-comment-end="h-Namespaces-Wikimedia_service"></span></h3></div> <p>The data on Wikidata Query Service contains the main namespace, <code>wdq</code>, to which queries to the main SPARQL endpoint are directed, and other auxiliary namespaces, listed below. To query data from different namespace, use endpoint URL <a class="external free" href="https://query.wikidata.org/bigdata/namespace/NAMESPACENAME/sparql">https://query.wikidata.org/bigdata/namespace/NAMESPACENAME/sparql</a>. </p> <div class="mw-heading mw-heading4"><h4 id="Categories" data-mw-thread-id="h-Categories-Namespaces"><span data-mw-comment-start="" id="h-Categories-Namespaces"></span>Categories<span data-mw-comment-end="h-Categories-Namespaces"></span></h4></div> <p><i>Please see full description on <a href="/wiki/Special:MyLanguage/Wikidata_query_service/Categories" title="Special:MyLanguage/Wikidata query service/Categories">Categories documentation page</a>.</i> </p><p>Wikidata Query Service also provides access to the category graph of select wikis. The list of covered wikis can be seen here: <a class="external free" href="https://noc.wikimedia.org/conf/dblists/categories-rdf.dblist">https://noc.wikimedia.org/conf/dblists/categories-rdf.dblist</a> </p><p>The category namespace name is <code>categories</code>. The SPARQL endpoint for accessing it is <a class="external free" href="https://query.wikidata.org/bigdata/namespace/categories/sparql">https://query.wikidata.org/bigdata/namespace/categories/sparql</a>. </p><p>Please see <a href="/wiki/Special:MyLanguage/Wikidata_query_service/Categories" title="Special:MyLanguage/Wikidata query service/Categories">Categories page</a> for detailed documentation. </p> <div class="mw-heading mw-heading4"><h4 id="DCAT-AP" data-mw-thread-id="h-DCAT-AP-Namespaces"><span data-mw-comment-start="" id="h-DCAT-AP-Namespaces"></span>DCAT-AP<span data-mw-comment-end="h-DCAT-AP-Namespaces"></span></h4></div> <p>The <a href="https://en.wikipedia.org/wiki/Data_Catalog_Vocabulary" class="extiw" title="w:Data Catalog Vocabulary">DCAT-AP</a> data for Wikidata is available as SPARQL at <a class="external free" href="https://query.wikidata.org/bigdata/namespace/dcatap/sparql">https://query.wikidata.org/bigdata/namespace/dcatap/sparql</a> endpoint. </p><p>The source for the data is: <a class="external free" href="https://dumps.wikimedia.org/wikidatawiki/entities/dcatap.rdf">https://dumps.wikimedia.org/wikidatawiki/entities/dcatap.rdf</a> </p><p>Example query to retrieve data: </p> <div class="mw-highlight mw-highlight-lang-sparql mw-content-ltr" dir="ltr"><pre><span></span><span class="k">PREFIX</span> <span class="nn">dcat</span><span class="p">:</span> <span class="nl"><http://www.w3.org/ns/dcat#></span> <span class="k">PREFIX</span> <span class="nn">dct</span><span class="p">:</span> <span class="nl"><http://purl.org/dc/terms/></span> <span class="k">SELECT</span> <span class="nv">?url</span> <span class="nv">?date</span> <span class="nv">?size</span> <span class="k">WHERE</span> <span class="p">{</span> <span class="nl"><https://www.wikidata.org/about#catalog></span> <span class="nn">dcat</span><span class="p">:</span><span class="nt">dataset</span> <span class="nv">?dump</span> <span class="p">.</span> <span class="nv">?dump</span> <span class="nn">dcat</span><span class="p">:</span><span class="nt">distribution</span> <span class="p">[</span> <span class="nn">dct</span><span class="p">:</span><span class="nt">format</span> <span class="s">"application/json"</span> <span class="p">;</span> <span class="nn">dcat</span><span class="p">:</span><span class="nt">downloadURL</span> <span class="nv">?url</span> <span class="p">;</span> <span class="nn">dct</span><span class="p">:</span><span class="nt">issued</span> <span class="nv">?date</span> <span class="p">;</span> <span class="nn">dcat</span><span class="p">:</span><span class="nt">byteSize</span> <span class="nv">?size</span> <span class="p">]</span> <span class="p">.</span> <span class="p">}</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Linked_Data_Fragments_endpoint" data-mw-thread-id="h-Linked_Data_Fragments_endpoint-Wikimedia_service"><span data-mw-comment-start="" id="h-Linked_Data_Fragments_endpoint-Wikimedia_service"></span>Linked Data Fragments endpoint<span data-mw-comment-end="h-Linked_Data_Fragments_endpoint-Wikimedia_service"></span></h3></div> <p>We also support querying the database using <a rel="nofollow" class="external text" href="http://linkeddatafragments.org/">Triple Pattern Fragments</a> interface. This allows to cheaply and efficiently browse triple data where one or two components of the triple is known and you need to retrieve all triples that match this template. See <a rel="nofollow" class="external text" href="http://linkeddatafragments.org/concept/">more information at the Linked Data Fragments site</a>. </p><p>The interface can be accessed by the URL: <code><a class="external text" href="https://query.wikidata.org/bigdata/ldf">https://query.wikidata.org/bigdata/ldf</a></code>. This service is implemented on the top of Blazegraph database, so it will have the same lag as the Query Service. Example requests: </p> <ul><li><a class="external free" href="https://query.wikidata.org/bigdata/ldf?subject=http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ146">https://query.wikidata.org/bigdata/ldf?subject=http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ146</a> - all triples with subject <a href="https://www.wikidata.org/wiki/Special:EntityPage/Q146" class="extiw" title="d:Special:EntityPage/Q146">cat <small>(Q146)</small></a></li> <li><a class="external free" href="https://query.wikidata.org/bigdata/ldf?subject=&predicate=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label&object=%22London%22%40en">https://query.wikidata.org/bigdata/ldf?subject=&predicate=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label&object=%22London%22%40en</a> - all triples that have English label "London"</li> <li><a class="external free" href="https://query.wikidata.org/bigdata/ldf?predicate=http%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2FP212&object=%22978-0-262-03293-3%22">https://query.wikidata.org/bigdata/ldf?predicate=http%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2FP212&object=%22978-0-262-03293-3%22</a> All triples that have <code>978-0-262-03293-3</code> as the value for <a href="https://www.wikidata.org/wiki/Special:EntityPage/P212" class="extiw" title="d:Special:EntityPage/P212">ISBN-13 <small>(P212)</small></a>. The following shell command uses <code>curl</code> to build the same URL and obtain the same data.</li></ul> <div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span>$<span class="w"> </span>curl<span class="w"> </span><span class="se">\</span> <span class="w"> </span>--get<span class="w"> </span><span class="se">\</span> <span class="w"> </span>-H<span class="w"> </span><span class="s1">'Accept: application/rdf+xml'</span><span class="w"> </span><span class="se">\</span> <span class="w"> </span>--data-urlencode<span class="w"> </span><span class="s1">'predicate=http://www.wikidata.org/prop/direct/P212'</span><span class="w"> </span><span class="se">\</span> <span class="w"> </span>--data-urlencode<span class="w"> </span><span class="s1">'object="978-0-262-03293-3"'</span><span class="w"> </span><span class="se">\</span> <span class="w"> </span><span class="s1">'https://query.wikidata.org/bigdata/ldf'</span> </pre></div> <p>Note that only full URLs are currently supported for the <code>subject</code>, <code>predicate</code> and <code>object</code> parameters. </p><p>By default, HTML interface is displayed, however several data formats are available, defined by <code>Accept</code> HTTP header. </p> <table class="wikitable"> <caption>Available data formats </caption> <tbody><tr> <th>Accept </th> <th>Format </th></tr> <tr> <td>text/html </td> <td>Default HTML browsing interface </td></tr> <tr> <td>text/turtle </td> <td><a rel="nofollow" class="external text" href="https://www.w3.org/TR/turtle/">Turtle</a> format </td></tr> <tr> <td>application/ld+json </td> <td><a rel="nofollow" class="external text" href="https://www.w3.org/TR/json-ld/">JSON-LD</a> format </td></tr> <tr> <td>application/n-triples </td> <td><a rel="nofollow" class="external text" href="https://www.w3.org/TR/n-triples/">N-Triples</a> format </td></tr> <tr> <td>application/rdf+xml </td> <td><a rel="nofollow" class="external text" href="https://www.w3.org/TR/REC-rdf-syntax/">RDF/XML</a> format </td></tr></tbody></table> <p>The data is returned in pages, page size being 100 triples. The pages are numbered starting from 1, and page number is defined by <code>page</code> parameter. </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Standalone_service" data-mw-thread-id="h-Standalone_service"><span data-mw-comment-start="" id="h-Standalone_service"></span>Standalone service<span data-mw-comment-end="h-Standalone_service"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Standalone_service","replies":["h-Installing-Standalone_service","h-Loading_data-Standalone_service","h-Scripts-Standalone_service","h-Updater_options-Standalone_service","h-Configurable_properties-Standalone_service"]}}--></div> <p>As the service is open source software, it is also possible to run the service on any user's server, by using the instructions provided below. </p><p>The hardware recommendations can be found in <a rel="nofollow" class="external text" href="https://wiki.blazegraph.com/wiki/index.php/Hardware_Configuration">Blazegraph documentation</a>. </p><p>If you plan to run the service against non-Wikidata Wikibase instance, please see <a href="/wiki/Special:MyLanguage/Wikidata_Query_Service/Implementation#Non-Wikidata_deployment" title="Special:MyLanguage/Wikidata Query Service/Implementation">further instructions</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Installing" data-mw-thread-id="h-Installing-Standalone_service"><span data-mw-comment-start="" id="h-Installing-Standalone_service"></span>Installing<span data-mw-comment-end="h-Installing-Standalone_service"></span></h3></div> <p>In order to install the service, it is recommended that you download the full service package as a ZIP file, e.g. <a rel="nofollow" class="external text" href="http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.wikidata.query.rdf%22%20AND%20a%3A%22service%22">from Maven Central</a>, with group ID <code>org.wikidata.query.rdf</code> and artifact ID <code>service</code> , or clone the source distribution at <a rel="nofollow" class="external free" href="https://github.com/wikimedia/wikidata-query-rdf/">https://github.com/wikimedia/wikidata-query-rdf/</a> and build it with "mvn package". The package ZIP will be in the <code>dist/target</code> directory under <code>service-VERSION-dist.zip</code>. </p><p>The package contains the Blazegraph server as a .war application, the libraries needed to run the updater service to fetch fresh data from the wikidata site, scripts to make various tasks easier, and the <a href="#GUI">GUI</a> in the <code>gui</code> subdirectory. If you want to use the GUI, you will have to configure your HTTP server to serve it. </p><p>By default, only the SPARQL endpoint at <a rel="nofollow" class="external free" href="http://localhost:9999/bigdata/namespace/wdq/sparql">http://localhost:9999/bigdata/namespace/wdq/sparql</a> is configured, and the default Blazegraph GUI is available at <a rel="nofollow" class="external free" href="http://localhost:9999/bigdata/">http://localhost:9999/bigdata/</a>. Note that in the default configuration, both are accessible only from localhost. You will need to provide external endpoints and an appropriate access control if you intend to access them from outside. </p> <div class="mw-heading mw-heading4"><h4 id="Using_snapshot_versions" data-mw-thread-id="h-Using_snapshot_versions-Installing"><span data-mw-comment-start="" id="h-Using_snapshot_versions-Installing"></span>Using snapshot versions<span data-mw-comment-end="h-Using_snapshot_versions-Installing"></span></h4></div> <p>If you want to install an un-released snapshot version (usually this is necessary if released version has a bug which is fixed but new release is not available yet) and do not want to compile your own binaries, you can use either: </p> <ul><li><a rel="nofollow" class="external free" href="https://github.com/wikimedia/wikidata-query-deploy">https://github.com/wikimedia/wikidata-query-deploy</a> - deployment repo containing production binaries. Needs <code>git fat</code> working. Check it out and do "<code>git fat pull</code>".</li> <li>Archiva snapshot deployments at <a class="external free" href="https://archiva.wikimedia.org/#artifact/org.wikidata.query.rdf/service">https://archiva.wikimedia.org/#artifact/org.wikidata.query.rdf/service</a> - choose the latest version, then Artifacts, and select the latest package for download.</li></ul> <div class="mw-heading mw-heading3"><h3 id="Loading_data" data-mw-thread-id="h-Loading_data-Standalone_service"><span data-mw-comment-start="" id="h-Loading_data-Standalone_service"></span>Loading data<span data-mw-comment-end="h-Loading_data-Standalone_service"></span></h3></div> <table class="warning-message" style="background-color: var( --background-color-error-subtle, #ffe9e5 ); color: var( --color-base, #202122 ); border: 1px var( --border-color-error, #9f3526 ) solid; box-sizing: border-box; margin: 0.5em 0; padding: 0.5em;"><tbody><tr><td style="white-space: nowrap; vertical-align: top;"><span style="position: relative; top: -2px;"><span typeof="mw:File"><span><img alt="Warning" src="//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/18px-OOjs_UI_icon_notice-destructive.svg.png" decoding="async" width="18" height="18" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/27px-OOjs_UI_icon_notice-destructive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/b/bf/OOjs_UI_icon_notice-destructive.svg/36px-OOjs_UI_icon_notice-destructive.svg.png 2x" data-file-width="20" data-file-height="20"/></span></span></span> <b>Warning:</b> </td><td style="padding-left: 0.5em vertical-align: top;">As of 2020, in Wikimedia servers it will take about 12 days to get all data in the dump imported, and another 12 days to make the query service catching up the lag.</td></tr></tbody></table> <p>Further install procedure is described in detail in the <a rel="nofollow" class="external text" href="https://github.com/wikimedia/wikidata-query-rdf/blob/master/docs/getting-started.md">Getting Started document</a> which is part of the distribution, and involves the following steps: </p> <ol><li>Download recent RDF dump from <a class="external free" href="https://dumps.wikimedia.org/wikidatawiki/entities/">https://dumps.wikimedia.org/wikidatawiki/entities/</a> (the RDF one is the one ending in <code>.ttl.gz</code>).</li> <li>Pre-process data with the <code>munge.sh</code> script. This creates a set of TTL files with preprocessed data, with names like <code>wikidump-000000001.ttl.gz</code>, etc. See options for the script below.</li> <li>Start Blazegraph service by running the <code>runBlazegraph.sh</code> script.</li> <li>Load the data into the service by using <code><a rel="nofollow" class="external text" href="https://github.com/wikimedia/wikidata-query-rdf/blob/master/dist/src/script/loadData.sh">loadData.sh</a></code>. Note that loading data is usually significantly slower than pre-processing, so you can start loading as soon as several preprocessed files are ready. Loading can be restarted from any file by using the options as described below.</li> <li>After all the data is loaded, start the Updater service by using <code>runUpdate.sh</code>.</li></ol> <div class="mw-heading mw-heading4"><h4 id="Loading_categories" data-mw-thread-id="h-Loading_categories-Loading_data"><span data-mw-comment-start="" id="h-Loading_categories-Loading_data"></span>Loading categories<span data-mw-comment-end="h-Loading_categories-Loading_data"></span></h4></div> <p>If you also want to load <a href="#Categories">category data</a>, please do the following: </p> <ol><li>Create namespace, e.g. <code>categories</code>: <code>createNamespace.sh categories</code></li> <li>Load data into it: <code>forAllCategoryWikis.sh loadCategoryDump.sh categories</code></li></ol> <p>Note that these scripts only load data from Wikimedia wikis according to Wikimedia settings. If you need to work with other wiki, you may need to change some variables in the scripts. </p><p><br/> </p> <div class="mw-heading mw-heading3"><h3 id="Scripts" data-mw-thread-id="h-Scripts-Standalone_service"><span data-mw-comment-start="" id="h-Scripts-Standalone_service"></span>Scripts<span data-mw-comment-end="h-Scripts-Standalone_service"></span></h3></div> <p>The following useful scripts are part of the distribution: </p> <div class="mw-heading mw-heading4"><h4 id="munge.sh" data-mw-thread-id="h-munge.sh-Scripts"><span data-mw-comment-start="" id="h-munge.sh-Scripts"></span>munge.sh<span data-mw-comment-end="h-munge.sh-Scripts"></span></h4></div> <p>Pre-process data from RDF dump for loading. </p> <table class="wikitable"> <tbody><tr> <th>Option </th> <th>Required? </th> <th>Explanation </th></tr> <tr> <td>-f <i>filename</i> </td> <td style="background-color:#FFE0B2;vertical-align:middle;text-align:center;" class="table-yes">Required </td> <td>Filename of the RDF dump </td></tr> <tr> <td>-d <i>directory</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Directory where the processed files will be written, default is current directory </td></tr> <tr> <td>-l <i>language</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>If specified, only labels for the given language will be retained. Use this option if you need only one language, as it may improve performance, reduce the database size and simplify queries. </td></tr> <tr> <td>-s </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>If specified, the data about sitelinks is excluded. Use this option if you do not need to query sitelinks, as this may improve performance and reduce the database size. </td></tr> <tr> <td>-c <i>size</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Use this option to override the default chunk size. Too big chunks may time out when importing. </td></tr></tbody></table> <p>Example: </p><p><code>./munge.sh -c 50000 -f data/wikidata-20150427-all-BETA.ttl.gz -d data -l en -s</code> </p> <div class="mw-heading mw-heading4"><h4 id="loadData.sh" data-mw-thread-id="h-loadData.sh-Scripts"><span data-mw-comment-start="" id="h-loadData.sh-Scripts"></span><a rel="nofollow" class="external text" href="https://github.com/wikimedia/wikidata-query-rdf/blob/master/dist/src/script/loadData.sh">loadData.sh</a><span data-mw-comment-end="h-loadData.sh-Scripts"></span></h4></div> <p>Load processed data into Blazegraph. Requires <code>curl</code> to be installed. </p> <table class="wikitable"> <tbody><tr> <th>Option </th> <th>Required? </th> <th>Explanation </th></tr> <tr> <td>-n <i>namespace</i> </td> <td style="background-color:#FFE0B2;vertical-align:middle;text-align:center;" class="table-yes">Required </td> <td>Specifies the graph namespace into which the data is loaded, which should be <b>wdq</b> for WDQS data </td></tr> <tr> <td>-d <i>directory</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Directory where processed files are stored, by default the current directory </td></tr> <tr> <td>-h <i>host</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Hostname of the SPARQL endpoint, by default localhost </td></tr> <tr> <td>-c <i>context</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Context URL of the SPARQL endpoint, by default bigdata - usually doesn't need to be changed for WDQS </td></tr> <tr> <td>-s <i>start</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Number of the processed file to start with, by default 1 </td></tr> <tr> <td>-e <i>end</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Number of the processed file to end with </td></tr></tbody></table> <p>Example: </p><p><code>./loadData.sh -n wdq -d `pwd`/data</code> </p> <div class="mw-heading mw-heading4"><h4 id="runBlazegraph.sh" data-mw-thread-id="h-runBlazegraph.sh-Scripts"><span data-mw-comment-start="" id="h-runBlazegraph.sh-Scripts"></span>runBlazegraph.sh<span data-mw-comment-end="h-runBlazegraph.sh-Scripts"></span></h4></div> <p>Run the Blazegraph service. </p> <table class="wikitable"> <tbody><tr> <th>Option </th> <th>Required? </th> <th>Explanation </th></tr> <tr> <td>-d <i>directory</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Home directory of the Blazegraph installation, by default the same directory where the script is </td></tr> <tr> <td>-c <i>context</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Context URL of the SPARQL endpoint, by default bigdata - usually doesn't need to be changed for WDQS </td></tr> <tr> <td>-p <i>port</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Port number of the SPARQL service, by default 9999 </td></tr> <tr> <td>-o <i>options</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Add options to the command line </td></tr></tbody></table> <p>Example: </p><p><code>./runBlazegraph.sh</code> </p><p>Inside the script, there are two variables that one may want to edit: </p> <div class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr"><pre><span></span><span class="c1"># Q-id of the default globe</span> <span class="nv">DEFAULT_GLOBE</span><span class="o">=</span><span class="m">2</span> <span class="c1"># Blazegraph HTTP User Agent for federation</span> <span class="nv">USER_AGENT</span><span class="o">=</span><span class="s2">"Wikidata Query Service; https://query.wikidata.org/"</span><span class="p">;</span> </pre></div> <p>Also, the following environment variables are checked by the script (all of them are optional): </p> <table class="wikitable"> <tbody><tr> <th>Variable </th> <th>Default </th> <th>Explanation </th></tr> <tr> <td>HOST </td> <td>localhost </td> <td>Hostname for binding the Blazegraph service </td></tr> <tr> <td>PORT </td> <td>9999 </td> <td>Port for binding the Blazegraph service </td></tr> <tr> <td>DIR </td> <td><i>directory where the script is located</i> </td> <td>Directory where config files are stored </td></tr> <tr> <td>HEAP_SIZE </td> <td>16g </td> <td>Java heap size for Blazegraph </td></tr> <tr> <td>MEMORY </td> <td><code class="mw-highlight mw-highlight-lang-sh mw-content-ltr" dir="ltr">-Xms<span class="si">${</span><span class="nv">HEAP_SIZE</span><span class="si">}</span><span class="w"> </span>-Xmx<span class="si">${</span><span class="nv">HEAP_SIZE</span><span class="si">}</span></code> </td> <td>Full Java memory settings for Blazegraph </td></tr> <tr> <td>GC_LOGS </td> <td><i>see <a rel="nofollow" class="external text" href="https://github.com/wikimedia/wikidata-query-rdf/blob/master/dist/src/script/runBlazegraph.sh">the source</a></i> </td> <td>GC logging settings </td></tr> <tr> <td>CONFIG_FILE </td> <td>RWStore.properties </td> <td>Blazegraph configuration file location </td></tr> <tr> <td>BLAZEGRAPH_OPTS </td> <td><i>empty</i> </td> <td>Additional options, are passed as-is to the Java command line </td></tr></tbody></table> <div class="mw-heading mw-heading4"><h4 id="runUpdate.sh" data-mw-thread-id="h-runUpdate.sh-Scripts"><span data-mw-comment-start="" id="h-runUpdate.sh-Scripts"></span>runUpdate.sh<span data-mw-comment-end="h-runUpdate.sh-Scripts"></span></h4></div> <p>Run the Updater service. </p> <table class="wikitable"> <tbody><tr> <th>Option </th> <th>Required? </th> <th>Explanation </th></tr> <tr> <td>-n <i>namespace</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Specifies the graph namespace into which the data is loaded, should be <b>wdq</b> for WDQS data. Default: <b>wdq</b> </td></tr> <tr> <td>-h <i>host</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Hostname of the SPARQL endpoint, by default localhost </td></tr> <tr> <td>-c <i>context</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Context URL of the SPARQL endpoint, by default bigdata - usually doesn't need to be changed for WDQS </td></tr> <tr> <td>-l <i>language</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>If specified, only labels for given language will be retained. Use this option if you need only one language, as it may improve performance, reduce the database size and simplify queries. </td></tr> <tr> <td>-s </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>If specified, the data about sitelinks is excluded. Use this option of you do not need to query sitelinks, as this may improve performance and reduce the database size. </td></tr> <tr> <td>-t <i>secs</i> </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Timeout when communicating to Blazegraph, in seconds. </td></tr> <tr> <td>-N </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>This option causes the script to ignore options that may cause problems when running second Updater while the first is already running. Use it when running secondary Updater e.g. to catch up specific item with <code>--ids</code> (see below). </td></tr> <tr> <td>-S </td> <td style="background-color:#BBDEFB;vertical-align:middle;text-align:center;" class="table-no">Optional </td> <td>Log to console instead of log files. Useful when running the script from the command line for maintenance tasks. </td></tr></tbody></table> <p>It is recommended that the settings for the <code>-l</code> and <code>-s</code> options (or absence thereof) be the same for munge.sh and runUpdate.sh, otherwise data may not be updated properly. </p><p>Example: </p><p><code>./runUpdate.sh</code> </p><p>Also, the following environment variables are checked by the script (all of them are optional): </p> <table class="wikitable"> <tbody><tr> <th>Variable </th> <th>Default </th> <th>Explanation </th></tr> <tr> <td>UPDATER_OPTS </td> <td><i>empty</i> </td> <td>Additional options, are passed as-is to the Java command line </td></tr></tbody></table> <div class="mw-heading mw-heading3"><h3 id="Updater_options" data-mw-thread-id="h-Updater_options-Standalone_service"><span data-mw-comment-start="" id="h-Updater_options-Standalone_service"></span>Updater options<span data-mw-comment-end="h-Updater_options-Standalone_service"></span></h3></div> <p>The following options works with Updater app. </p><p>They should be given to the <code>runUpdate.sh</code> script as additional options after <code>--</code>, e.g.: <code>runUpdate.sh -- -v</code>. </p> <table class="wikitable"> <caption>Options for the Updater </caption> <tbody><tr> <th>Option </th> <th>Long option </th> <th>Meaning </th></tr> <tr> <td>-v </td> <td>--verbose </td> <td>Verbose mode </td></tr> <tr> <td>-s TIMESTAMP </td> <td>--start TIMESTAMP </td> <td>Start data collection from certain timestamp, in <code>2015-02-11T17:11:08Z</code> or <code>20150211170100</code> format. </td></tr> <tr> <td> </td> <td>--keepTypes </td> <td>Keep all type statements </td></tr> <tr> <td> </td> <td>--ids ID1,ID2,... </td> <td>Update certain IDs and exit </td></tr> <tr> <td> </td> <td>--idrange ID1-ID2 </td> <td>Update range of IDs and exit </td></tr> <tr> <td>-d SECONDS </td> <td>--pollDelay SECONDS </td> <td>How long to sleep when no new data is available </td></tr> <tr> <td>-t NUMBER </td> <td>--threadCount NUMBER </td> <td>How many threads to use when fetching Wikibase data </td></tr> <tr> <td>-b NUMBER </td> <td>--batchSize NUMBER </td> <td>How many changes to fetch from RecentChanges API </td></tr> <tr> <td>-V </td> <td>--verify </td> <td>Verify data after loading (SLOW! For debug use only) </td></tr> <tr> <td>-T SECONDS </td> <td>--tailPollerOffset SECONDS </td> <td>Use secondary trailing poller with given offset behind the main one </td></tr> <tr> <td> </td> <td>--entityNamespaces NUMBER,NUMBER,... </td> <td>List of Wikibase namespaces to check for changes </td></tr> <tr> <td>-W </td> <td>--wikibaseUrl URL </td> <td>URL to use when talking to Wikibase. E.g. <code><a class="external free" href="https://www.wikidata.org">https://www.wikidata.org</a></code>. Must be set if updates do not come from Wikidata. </td></tr> <tr> <td>-U </td> <td>--conceptUri URL </td> <td>URL base of the URLs used to represent Wikibase entities in RDF. E.g. <code><a class="external free" href="https://www.wikidata.org">http://www.wikidata.org</a></code>. Must be set if the Wikibase instance does not use Wikidata-based prefixes. </td></tr> <tr> <td> </td> <td>--commonsUri URL </td> <td>Commons URI for <a href="https://meta.wikimedia.org/wiki/Special:MyLanguage/Structured_Data_on_Commons" class="extiw" title="m:Special:MyLanguage/Structured Data on Commons">SDC</a> support. Both <code>--conceptUri</code> and <code>--commonsUri</code> should be set for this to work. </td></tr> <tr> <td> </td> <td>--wikibaseScheme SCHEME </td> <td>URL scheme (http, https) to use when talking to Wikibase. <span style="color:#d33">(deprecated)</span> Use wikibaseUrl above instead. </td></tr> <tr> <td> </td> <td>--wikibaseHost HOSTNAME </td> <td>Hostname to use when talking to Wikibase. <span style="color:#d33">(deprecated)</span> Use wikibaseUrl above instead. </td></tr> <tr> <td>-I </td> <td>--init </td> <td>If specified together with start time, this time is marked in the database as most recent change time, and future requests would be using it as starting point even if no newer data has been found. </td></tr> <tr> <td> </td> <td>--constraints </td> <td>Load <a href="/wiki/Special:MyLanguage/Wikibase_Quality_Extensions" title="Special:MyLanguage/Wikibase Quality Extensions">constraints violations</a> for updated items via <code>constraintsrdf</code> API. </td></tr> <tr> <td>-K SERVERS </td> <td>--kafka SERVERS </td> <td>If specified, Updater will use Kafka as the update source and the specified servers as brokers. E.g. <code>kafka1001.eqiad.wmnet:9092,kafka1002.eqiad.wmnet:9092,kafka1003.eqiad.wmnet:9092</code> </td></tr> <tr> <td>-C NAME </td> <td>--consumer NAME </td> <td>Kafka consumer name. It is a good idea to set it to the host name or something based on it. </td></tr> <tr> <td>-c NAME1,NAME2 </td> <td>--cluster NAME1,NAME2 </td> <td>Kafka cluster names. If specified, the Kafka topic names will be prefixed by cluster names, so instead of <code>topic1</code> there would be <code>NAME1.topic1</code> and <code>NAME2.topic2</code>. </td></tr> <tr> <td> </td> <td>--resetKafka </td> <td>Reset Kafka offsets </td></tr> <tr> <td> </td> <td>--apiPath </td> <td>Path to the API, e.g. <code>/w/api.php</code> (default) or <code>/api.php</code>. <span style="color:#008000">(introduced in <a href="https://gerrit.wikimedia.org/r/q/I78c222fe8bbcdacbc85c9d0f4c6378006c09fed7" class="extiw" title="gerrit:q/I78c222fe8bbcdacbc85c9d0f4c6378006c09fed7">I78c222fe8b</a>)</span> </td></tr> <tr> <td> </td> <td>--entityDataPath </td> <td>Path to the entities, e.g. <code>/wiki/Special:EntityData/</code> (default) or <code>/Special:EntityData/</code>. <span style="color:#008000">(introduced in <a href="https://gerrit.wikimedia.org/r/q/I78c222fe8bbcdacbc85c9d0f4c6378006c09fed7" class="extiw" title="gerrit:q/I78c222fe8bbcdacbc85c9d0f4c6378006c09fed7">I78c222fe8b</a>)</span> </td></tr></tbody></table> <div class="mw-heading mw-heading3"><h3 id="Configurable_properties" data-mw-thread-id="h-Configurable_properties-Standalone_service"><span data-mw-comment-start="" id="h-Configurable_properties-Standalone_service"></span>Configurable properties<span data-mw-comment-end="h-Configurable_properties-Standalone_service"></span></h3></div> <p>The following properties are configurable via adding them to the script run command in the scripts above: </p> <table class="wikitable"> <tbody><tr> <th>Name </th> <th>Meaning </th> <th>Default </th></tr> <tr> <td>wikibaseServiceWhitelist </td> <td>Filename of remote service whitelist. Applies to Blazegraph. </td> <td>whitelist.txt </td></tr> <tr> <td>org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceFactory.config </td> <td>Config file for <a href="/wiki/Special:MyLanguage/Wikidata_query_service/User_Manual/MWAPI" title="Special:MyLanguage/Wikidata query service/User Manual/MWAPI">MWAPI integration</a> </td> <td>mwservices.json </td></tr> <tr> <td>com.bigdata.rdf.sail.sparql.PrefixDeclProcessor.additionalDeclsFile </td> <td>Filename that contains additional prefix definitions. The syntax is as in SPARQL query. These definitions will be loaded by Blazegraph and available for all queries. </td> <td> </td></tr> <tr> <td>wikibaseConceptUri </td> <td>URL prefix for Wikibase data, which is used in RDF representation of entities. Needs to be set if the dataset does not use Wikidata prefixes. </td> <td><a class="external free" href="https://www.wikidata.org">http://www.wikidata.org</a> </td></tr> <tr> <td>commonsConceptUri </td> <td>URL prefix for <a href="https://meta.wikimedia.org/wiki/Special:MyLanguage/Structured_Data_on_Commons" class="extiw" title="m:Special:MyLanguage/Structured Data on Commons">Structured Data on Commons</a> support. Both <code>wikibaseConceptUri</code> and <code>commonsConceptUri</code> should be set for it to work. </td> <td> </td></tr> <tr> <td>wikibaseHost </td> <td>Hostname of the wikibase instance. Applies to both Blazegraph and Updater. <span style="color:#d33">(deprecated)</span> Use wikibaseConceptUri above. </td> <td>www.wikidata.org </td></tr> <tr> <td>org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer.noGlobe </td> <td>Default globe value for coordinates that have no globe. "2" would mean that entity Q2 is the default globe. "0" means no default globe. Applies to Blazegraph. </td> <td>0 </td></tr> <tr> <td>org.wikidata.query.rdf.tool.rdf.RdfRepository.timeout </td> <td>Timeout when communicating with RDF repository, in seconds. Applies to Updater. </td> <td>-1 </td></tr> <tr> <td>org.wikidata.query.rdf.tool.wikibase.WikibaseRepository.timeout </td> <td>Timeout when communicating with wikibase repository, in milliseconds. Applies to Updater. </td> <td>5000 </td></tr> <tr> <td>http.userAgent </td> <td>User agent that the service would use while calling other services </td> <td> </td></tr> <tr> <td>http.proxyHost http.proxyPort <p>https.proxyHost https.proxyPort </p> </td> <td>Proxy settings used while calling other services </td> <td> </td></tr> <tr> <td>wikibaseMaxDaysBack </td> <td>How many days back we can request the recent changes data from Updater. If the database is more than this number of days older, it should be reloaded from more recent dump. </td> <td>30 </td></tr></tbody></table> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Missing_features" data-mw-thread-id="h-Missing_features"><span data-mw-comment-start="" id="h-Missing_features"></span>Missing features<span data-mw-comment-end="h-Missing_features"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Missing_features","replies":[]}}--></div> <p>Below are features which are currently not supported: </p> <ul><li>Redirects are only represented as <a href="/wiki/Special:MyLanguage/Wikibase/Indexing/RDF_Dump_Format" title="Special:MyLanguage/Wikibase/Indexing/RDF Dump Format">owl:sameAs triple</a>, but do not express any equivalence in the data and have no special support.</li></ul> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Contacts" data-mw-thread-id="h-Contacts"><span data-mw-comment-start="" id="h-Contacts"></span>Contacts<span data-mw-comment-end="h-Contacts"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Contacts","replies":[]}}--></div> <p>If you notice anything wrong with the service, you can contact the <a href="/wiki/Wikimedia_Discovery" title="Wikimedia Discovery">Discovery team</a> by email on the list <code>discovery@lists.wikimedia.org</code> or on the <a href="/wiki/Special:MyLanguage/MediaWiki_on_IRC" title="Special:MyLanguage/MediaWiki on IRC">IRC channel</a> <code>#wikimedia-discovery</code>. </p><p>Bugs can also be submitted to <a href="/wiki/Special:MyLanguage/Phabricator" title="Special:MyLanguage/Phabricator">Phabricator</a><span style="display:none"><a href="/wiki/Phabricator" title="Phabricator"> </a></span> and tracked on the <a href="https://phabricator.wikimedia.org/tag/discovery/" class="extiw" title="phab:tag/discovery/">Discovery Phabricator board</a>. </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="See_also" data-mw-thread-id="h-See_also"><span data-mw-comment-start="" id="h-See_also"></span>See also<span data-mw-comment-end="h-See_also"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-See_also","replies":[]}}--></div> <ul><li><a href="https://iw.toolforge.org/wdq2sparql/w2s.php" class="extiw" title="toollabs:wdq2sparql/w2s.php">WDQ to SPARQL syntax translator</a></li> <li><a href="https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples" class="extiw" title="d:Wikidata:SPARQL query service/queries/examples">SPARQL Query examples</a></li> <li><a href="/wiki/Special:MyLanguage/Wikimedia_Discovery" title="Special:MyLanguage/Wikimedia Discovery">Discovery team</a></li> <li><a href="/wiki/Special:MyLanguage/Wikidata_Query_Service/Implementation" title="Special:MyLanguage/Wikidata Query Service/Implementation">WDQS Implementation notes</a></li> <li><a rel="nofollow" class="external text" href="http://programminghistorian.org/lessons/graph-databases-and-SPARQL">An introduction to SPARQL query syntax</a></li> <li><a href="/wiki/Special:MyLanguage/Wikibase/Indexing/RDF_Dump_Format" title="Special:MyLanguage/Wikibase/Indexing/RDF Dump Format">RDF dump format</a><span style="display:none"><a href="/wiki/Wikibase/Indexing/RDF_Dump_Format" title="Wikibase/Indexing/RDF Dump Format"> </a></span></li></ul> <!-- NewPP limit report Parsed by mw‐web.eqiad.main‐7c479b968‐vtdtm Cached time: 20241116054359 Cache expiry: 2592000 Reduced expiry: false Complications: [show‐toc] DiscussionTools time usage: 0.063 seconds CPU time usage: 0.427 seconds Real time usage: 1.402 seconds Preprocessor visited node count: 2118/1000000 Post‐expand include size: 28744/2097152 bytes Template argument size: 19366/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 25/500 Unstrip recursion depth: 0/20 Unstrip post‐expand size: 40578/5000000 bytes Lua time usage: 0.019/10.000 seconds Lua memory usage: 1188267/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 999.047 1 -total 27.71% 276.787 7 Template:SPARQL 7.42% 74.156 2 Template:SPARQL2 6.26% 62.560 4 Template:ItemOrNot 3.51% 35.075 2 Template:Ll 2.77% 27.658 2 Template:Warning 2.58% 25.734 1 Template:P 2.01% 20.051 2 Template:Required 1.99% 19.902 4 Template:Pagelang 1.99% 19.847 1 Template:Label --> <!-- Saved in parser cache with key mediawikiwiki:pcache:idhash:491213-0!canonical and timestamp 20241116054359 and revision id 6711618. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://www.mediawiki.org/w/index.php?title=Wikidata_Query_Service/User_Manual&oldid=6711618">https://www.mediawiki.org/w/index.php?title=Wikidata_Query_Service/User_Manual&oldid=6711618</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Special:Categories" title="Special:Categories">Categories</a>: <ul><li><a href="/wiki/Category:Wikidata_Query_Service" title="Category:Wikidata Query Service">Wikidata Query Service</a></li><li><a href="/wiki/Category:Discovery" title="Category:Discovery">Discovery</a></li><li><a href="/wiki/Category:Wikidata" title="Category:Wikidata">Wikidata</a></li><li><a href="/wiki/Category:SPARQL" title="Category:SPARQL">SPARQL</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 25 August 2024, at 00:31.</li> <li id="footer-info-copyright">Text is available under the <a rel="nofollow" class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-ShareAlike License</a>; additional terms may apply. Text in <a class="external text" href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents">the Help: namespace</a> is available under the <a rel="nofollow" class="external text" href="https://creativecommons.org/publicdomain/zero/1.0/">Creative Commons CC0 License</a>. By using this site, you agree to the <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use">Terms of Use</a> and <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy Policy</a>.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Project:About">About mediawiki.org</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Project:General_disclaimer">Disclaimers</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/www.mediawiki.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//m.mediawiki.org/w/index.php?title=Wikidata_Query_Service/User_Manual&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-65496f48b4-lgb2p","wgBackendResponseTime":125,"wgDiscussionToolsPageThreads":[{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Data_set","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Basics_-_Understanding_SPO_(Subject,_Predicate,_Object)_also_known_as_a_Semantic","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Basics_-_Understanding_Prefixes","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Extensions","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Label_service-Extensions","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Geospatial_search-Extensions","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Search_around_point-Geospatial_search","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Search_within_box-Geospatial_search","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Extended_functions-Extensions","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Distance_function-Extended_functions","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Coordinate_parts_functions-Extended_functions","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Decode_URL_functions-Extended_functions","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Automatic_prefixes-Extensions","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Extended_dates-Extensions","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Blazegraph_extensions-Extensions","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Federation-Extensions","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-MediaWiki_API-Extensions","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikimedia_service","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-GUI-Wikimedia_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Default_views-GUI","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Display_a_title-GUI","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-SPARQL_endpoint-Wikimedia_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Supported_formats-SPARQL_endpoint","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Query_limits-SPARQL_endpoint","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Explain_Query-SPARQL_endpoint","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Namespaces-Wikimedia_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Categories-Namespaces","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-DCAT-AP-Namespaces","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Linked_Data_Fragments_endpoint-Wikimedia_service","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Standalone_service","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Installing-Standalone_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Using_snapshot_versions-Installing","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Loading_data-Standalone_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Loading_categories-Loading_data","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Scripts-Standalone_service","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-munge.sh-Scripts","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-loadData.sh-Scripts","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-runBlazegraph.sh-Scripts","replies":[]},{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-runUpdate.sh-Scripts","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Updater_options-Standalone_service","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Configurable_properties-Standalone_service","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Missing_features","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Contacts","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-See_also","replies":[]}],"wgPageParseReport":{"discussiontools":{"limitreport-timeusage":"0.063"},"limitreport":{"cputime":"0.427","walltime":"1.402","ppvisitednodes":{"value":2118,"limit":1000000},"postexpandincludesize":{"value":28744,"limit":2097152},"templateargumentsize":{"value":19366,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":25,"limit":500},"unstrip-depth":{"value":0,"limit":20},"unstrip-size":{"value":40578,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 999.047 1 -total"," 27.71% 276.787 7 Template:SPARQL"," 7.42% 74.156 2 Template:SPARQL2"," 6.26% 62.560 4 Template:ItemOrNot"," 3.51% 35.075 2 Template:Ll"," 2.77% 27.658 2 Template:Warning"," 2.58% 25.734 1 Template:P"," 2.01% 20.051 2 Template:Required"," 1.99% 19.902 4 Template:Pagelang"," 1.99% 19.847 1 Template:Label"]},"scribunto":{"limitreport-timeusage":{"value":"0.019","limit":"10.000"},"limitreport-memusage":{"value":1188267,"limit":52428800}},"cachereport":{"origin":"mw-web.eqiad.main-7c479b968-vtdtm","timestamp":"20241116054359","ttl":2592000,"transientcontent":false}}});});</script> </body> </html>