Help:Contributing/query: Difference between revisions
Jump to navigation
Jump to search
docs: migrate contribution guide §9 (querying) from docs/contribution-guide.md (via create-page on MediaWiki MCP Server) |
Standardize: add copy button to block code snippets |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This page shows how to query the knowledge base with SPARQL. Start at the [[Help:Contributing]] hub if you are new here. | |||
== The endpoint == | |||
The public SPARQL endpoint is <code>https://wikibase.ronzz.org/sparql</code>. | |||
== A first query == | |||
All books in the knowledge base: | All books in the knowledge base: | ||
<syntaxhighlight lang="sparql"> | <syntaxhighlight lang="sparql" copy> | ||
SELECT ?book ?bookLabel WHERE { | SELECT ?book ?bookLabel WHERE { | ||
?book wdt:P1 wd:Q9 . # instance of (P1) → book (Q9) | ?book wdt:P1 wd:Q9 . # instance of (P1) → book (Q9) | ||
| Line 27: | Line 16: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The <code>wdt:</code> prefix reads the values of a property; <code>wd:</code> names an entity. On this instance, <code>instance of</code> is <code>P1</code> and <code>book</code> is <code>Q9</code>. | |||
The < | |||
The [https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial Wikidata SPARQL tutorial] works verbatim on this instance. For the full syntax reference, see [[Cheatsheets:SPARQL]]. | |||
The [https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial Wikidata SPARQL tutorial] works verbatim on this instance. | |||
== | == See also == | ||
* [[Help:Contributing]] — the hub | |||
* | |||
* [https://www.w3.org/TR/sparql11-query/ SPARQL 1.1 specification] (official) | * [https://www.w3.org/TR/sparql11-query/ SPARQL 1.1 specification] (official) | ||
Latest revision as of 09:46, 23 August 2026
This page shows how to query the knowledge base with SPARQL. Start at the Help:Contributing hub if you are new here.
The endpoint
The public SPARQL endpoint is https://wikibase.ronzz.org/sparql.
A first query
All books in the knowledge base:
SELECT ?book ?bookLabel WHERE {
?book wdt:P1 wd:Q9 . # instance of (P1) → book (Q9)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
The wdt: prefix reads the values of a property; wd: names an entity. On this instance, instance of is P1 and book is Q9.
The Wikidata SPARQL tutorial works verbatim on this instance. For the full syntax reference, see Cheatsheets:SPARQL.
See also
- Help:Contributing — the hub
- SPARQL 1.1 specification (official)