Help:Contributing/query: Difference between revisions

From Wikibase
Jump to navigation Jump to search
docs: migrate contribution guide §9 (querying) from docs/contribution-guide.md (via create-page on MediaWiki MCP Server)
 
Rewrite in code-guide style: strip translation markup, <code> for plain tokens, link the SPARQL cheatsheet (via update-page on MediaWiki MCP Server)
Line 1: Line 1:
<languages/>
This page shows how to query the knowledge base with SPARQL. Start at the [[Help:Contributing]] hub if you are new here.


<translate>
== The endpoint ==
<!--T:1-->
This page shows how to query the knowledge base with SPARQL. Start at the <tvar name="hub">[[Help:Contributing]]</tvar> hub if you are new here.
</translate>


== <translate><!--T:2--> The endpoint</translate> ==
The public SPARQL endpoint is <code>https://wikibase.ronzz.org/sparql</code>.


<translate>
== A first query ==
<!--T:3-->
The public SPARQL endpoint is <tvar name="ep"><syntaxhighlight lang="text" inline>https://wikibase.ronzz.org/sparql</syntaxhighlight></tvar>.
</translate>


== <translate><!--T:4--> A first query</translate> ==
<translate>
<!--T:5-->
All books in the knowledge base:
All books in the knowledge base:
</translate>


<syntaxhighlight lang="sparql">
<syntaxhighlight lang="sparql">
Line 27: Line 16:
</syntaxhighlight>
</syntaxhighlight>


<translate>
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>.
<!--T:6-->
The <tvar name="wdt"><syntaxhighlight lang="text" inline>wdt:</syntaxhighlight></tvar> prefix reads the values of a property; <tvar name="wd"><syntaxhighlight lang="text" inline>wd:</syntaxhighlight></tvar> names an entity. On this instance, <tvar name="p1"><syntaxhighlight lang="text" inline>instance of</syntaxhighlight></tvar> is <tvar name="pid"><syntaxhighlight lang="text" inline>P1</syntaxhighlight></tvar> and <tvar name="book"><syntaxhighlight lang="text" inline>book</syntaxhighlight></tvar> is <tvar name="qid"><syntaxhighlight lang="text" inline>Q9</syntaxhighlight></tvar>.
</translate>


<translate>
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]].
<!--T:7-->
The [https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial Wikidata SPARQL tutorial] works verbatim on this instance.
</translate>


== <translate><!--T:8--> See also</translate> ==
== See also ==


<translate>
* [[Help:Contributing]] — the hub
<!--T:9-->
* <tvar name="hub">[[Help:Contributing]]</tvar> — 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)
</translate>

Revision as of 17:26, 19 August 2026

Languages: English · français · Esperanto

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