Wikipedia
Connect Wikipedia articles with Wikidata statements and graph queries from SQL
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/wikipedia/index.md to help me query Wikipedia with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Full-text search English Wikipedia for 'apache arrow' (top 10).
Example output · captured
- Connector release
- v0.6.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10)
| title | snippet | url |
|---|---|---|
| Apache Arrow | Free and open-source software portal Apache Arrow is a language-agnostic softwa… | https://en.wikipedia.org/wiki/Apache_Arrow |
| Apache Parquet | open-source software portal Apache Arrow Apache Pig Apache Hive Apache Impala A… | https://en.wikipedia.org/wiki/Apache_Parquet |
| Data orientation | processing (OLAP). Examples of column-oriented formats include Apache ORC, Apac… | https://en.wikipedia.org/wiki/Data_orientation |
| Apache DataFusion | Apache DataFusion is an open-source, extensible analytical query engine written… | https://en.wikipedia.org/wiki/Apache_DataFusion |
| Wes McKinney | the reference book Python for Data Analysis. He is also the creator of Apache A… | https://en.wikipedia.org/wiki/Wes_McKinney |
Quick start
Choose where to run Wikipedia, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'wiki' AS wiki (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-wikipedia-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'wiki' AS wiki (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-wikipedia:0.6.0'
);
3. Run a query
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10)
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'wiki' AS wiki
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10)
Query Farm operates Wikipedia for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use wiki as the catalog alias for the query below.
4. Run a query
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10)
Technical details
- Verified connector release
- v0.6.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'wiki' AS wiki (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-wikipedia-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'wiki' AS wiki (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-wikipedia:0.6.0'
);
Overview
Wikipedia articles, Wikidata statements and graph queries for SQL
Connect encyclopedic articles to structured knowledge and join the results to local SQL tables. Use it for retrieval-augmented generation, fact lookup and entity enrichment. Article identity provides a reliable bridge to Wikidata without guessing from similar labels.
Data and context
Statements retain their rank, typed value, qualifiers and reference sources. Source revisions help identify observations taken at different times. Remote SPARQL supports graph patterns and property paths; RDF terms retain their lexical value, datatype and language. Results are bounded and cached locally.
Access
The worker calls the free MediaWiki API and Wikibase API. No API key is required. Queries require outbound access; language and endpoint options select the upstream site. Public endpoint availability and dataset coverage affect results.
Worker code is MIT. Wikipedia article text is CC-BY-SA; callers handle attribution and share-alike requirements. Wikidata structured data is CC0. Custom endpoints have their own terms.
Catalog
Everything wiki exposes once attached — read straight from the worker's
released build.
main 4 functions
Wikipedia / MediaWiki full-text search and page retrieval for SQL / RAG
Schema examples (5)
Full-text search English Wikipedia for 'apache arrow' (top 10).
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10);
| title | snippet | url |
|---|---|---|
| Apache Arrow | Free and open-source software portal Apache Arrow is a language-agnostic softwa… | https://en.wikipedia.org/wiki/Apache_Arrow |
| Apache Parquet | open-source software portal Apache Arrow Apache Pig Apache Hive Apache Impala A… | https://en.wikipedia.org/wiki/Apache_Parquet |
| Data orientation | processing (OLAP). Examples of column-oriented formats include Apache ORC, Apac… | https://en.wikipedia.org/wiki/Data_orientation |
| Apache DataFusion | Apache DataFusion is an open-source, extensible analytical query engine written… | https://en.wikipedia.org/wiki/Apache_DataFusion |
| Wes McKinney | the reference book Python for Data Analysis. He is also the creator of Apache A… | https://en.wikipedia.org/wiki/Wes_McKinney |
Fetch the English Wikipedia summary extract for the DuckDB article.
SELECT wiki.main.wiki_page('DuckDB');
Fetch the rich English summary row (title, extract, url) for DuckDB.
SELECT title, extract, url
FROM wiki.main.wiki_page_summary('DuckDB', lang := 'en');
Search English Wikipedia for 'apache arrow' and fetch the lead-paragraph summary of each of the top 3 matching articles with the wiki_page scalar
SELECT h.title, wiki.main.wiki_page(h.title) AS summary
FROM wiki.main.wiki_search('apache arrow', count := 3) AS h
ORDER BY h.title;
1 more example
Ground an article for RAG: the English summary extract and URL of the DuckDB article joined by page ID to the Wikidata item that article is linked to
SELECT s.title, e.entity_id, s.url, s.extract
FROM wiki.main.wiki_page_summary('DuckDB') AS s
JOIN wiki.main.wiki_entity('DuckDB') AS e USING (pageid)
ORDER BY s.title;
wiki_page (title VARCHAR, lang VARCHAR) +1 overload
Plain-text summary extract of an English Wikipedia page (NULL if missing)
wiki_page(title VARCHAR) → VARCHARwiki_page(title VARCHAR, lang VARCHAR) → VARCHAR
The English Wikipedia summary of DuckDB
SELECT wiki.main.wiki_page('DuckDB');
The German Wikipedia summary of DuckDB
SELECT wiki.main.wiki_page('DuckDB', 'de');
SELECT wiki.main.wiki_page('DuckDB') AS summary;
2 more examples
SELECT wiki.main.wiki_page('DuckDB', 'de') AS summary;
SELECT wiki.main.wiki_page('ThisPageDoesNotExist_zzz') IS NULL AS is_null;
wiki_entity (title VARCHAR, api_url := VARCHAR, cache_seconds := BIGINT, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, timeout_ms := BIGINT)
Resolve a Wikipedia article to its Wikidata identity
Resolve a Wikipedia article to its Wikidata identity
SELECT title, entity_id
FROM wiki.main.wiki_entity('Douglas Adams')
ORDER BY title;
Ground an article for RAG: the English summary extract and URL of the DuckDB article joined by page ID to the Wikidata item that article is linked to
SELECT s.title, e.entity_id, s.url, s.extract
FROM wiki.main.wiki_page_summary('DuckDB') AS s
JOIN wiki.main.wiki_entity('DuckDB') AS e USING (pageid)
ORDER BY s.title;
wiki_page_summary (title VARCHAR, api_url := VARCHAR, lang := VARCHAR)
Page summary as a row: title, extract, url, thumbnail_url, pageid
The English Wikipedia summary row for DuckDB
SELECT title, extract, url
FROM wiki.main.wiki_page_summary('DuckDB', lang := 'en');
SELECT title, url, pageid
FROM wiki.main.wiki_page_summary('DuckDB', lang := 'en');
SELECT count(*) AS n
FROM wiki.main.wiki_page_summary('ThisPageDoesNotExist_zzz');
wiki_search (query VARCHAR, api_url := VARCHAR, count := BIGINT, lang := VARCHAR, max_pages := BIGINT)
Full-text search over Wikipedia (or any MediaWiki); returns the unified schema
Top-10 English Wikipedia results for 'apache arrow'
SELECT title, snippet, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 10);
| title | snippet | url |
|---|---|---|
| Apache Arrow | Free and open-source software portal Apache Arrow is a language-agnostic softwa… | https://en.wikipedia.org/wiki/Apache_Arrow |
| Apache Parquet | open-source software portal Apache Arrow Apache Pig Apache Hive Apache Impala A… | https://en.wikipedia.org/wiki/Apache_Parquet |
| Data orientation | processing (OLAP). Examples of column-oriented formats include Apache ORC, Apac… | https://en.wikipedia.org/wiki/Data_orientation |
| Apache DataFusion | Apache DataFusion is an open-source, extensible analytical query engine written… | https://en.wikipedia.org/wiki/Apache_DataFusion |
| Wes McKinney | the reference book Python for Data Analysis. He is also the creator of Apache A… | https://en.wikipedia.org/wiki/Wes_McKinney |
Follow up to 3 sroffset pages of German results
SELECT title
FROM wiki.main.wiki_search('duckdb', lang := 'de', count := 5, max_pages := 3);
Search English Wikipedia for 'apache arrow' and fetch the lead-paragraph summary of each of the top 3 matching articles with the wiki_page scalar
SELECT h.title, wiki.main.wiki_page(h.title) AS summary
FROM wiki.main.wiki_search('apache arrow', count := 3) AS h
ORDER BY h.title;
2 more examples
SELECT title, url
FROM wiki.main.wiki_search('apache arrow', lang := 'en', count := 5);
SELECT count(*) AS n FROM wiki.main.wiki_search('duckdb', count := 5);
wikidata 6 functions
Structured Wikibase knowledge and remote graph queries
Schema examples (4)
Retrieve Wikidata entities in batches
SELECT entity_id, label
FROM wiki.wikidata.entity(['Q42'])
ORDER BY entity_id;
Douglas Adams's (Q42) best-ranked birth/death dates and places (places as item IDs), each labelled with its property's human-readable name by joining statements to the property entities
SELECT p.label AS property,
coalesce(s.value.time, s.value.entity_id) AS value
FROM wiki.wikidata.statements(['Q42'], rank := 'best') AS s
JOIN wiki.wikidata.entity(['P19', 'P20', 'P569', 'P570']) AS p ON s.property_id = p.entity_id
ORDER BY s.property_id;
Each spouse (P26) of Douglas Adams (Q42) with that statement's qualifiers, such as the P580 start time and P582 end time of the marriage
SELECT s.value.entity_id AS spouse, q.property_id AS qualifier,
coalesce(q.value.time, q.value.entity_id) AS qualifier_value
FROM wiki.wikidata.statements(['Q42'], property_id := 'P26') AS s
JOIN wiki.wikidata.qualifiers(['Q42'], property_id := 'P26') AS q USING (source_api, entity_revision, requested_id, statement_id)
ORDER BY spouse, qualifier;
How many distinct reference groups (sources) back each of Douglas Adams's (Q42) instance-of (P31) statements; statements with no source count 0
SELECT s.statement_id, s.value.entity_id AS class,
count(DISTINCT r.reference_hash) AS sources
FROM wiki.wikidata.statements(['Q42'], property_id := 'P31') AS s
LEFT JOIN wiki.wikidata.statement_references(['Q42'], property_id := 'P31') AS r USING (source_api, entity_revision, requested_id, statement_id)
GROUP BY s.statement_id, class
ORDER BY s.statement_id;
entity (ids VARCHAR[], api_url := VARCHAR, cache_seconds := BIGINT, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, timeout_ms := BIGINT)
Retrieve Wikidata entities in batches
Retrieve Wikidata entities in batches
SELECT entity_id, label
FROM wiki.wikidata.entity(['Q42'])
ORDER BY entity_id;
qualifiers (ids VARCHAR[], api_url := VARCHAR, cache_seconds := BIGINT, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, property_id := VARCHAR, rank := VARCHAR, timeout_ms := BIGINT)
Read contextual qualifiers attached to Wikidata statements
-
entity_idVARCHAR
-
textVARCHAR
-
languageVARCHAR
-
timeVARCHAR
-
time_precisionINTEGER
-
timezoneINTEGER
-
beforeBIGINT
-
afterBIGINT
-
calendar_modelVARCHAR
-
amountVARCHAR
-
lower_boundVARCHAR
-
upper_boundVARCHAR
-
unitVARCHAR
-
latitudeDOUBLE
-
longitudeDOUBLE
-
coordinate_precisionDOUBLE
-
globeVARCHAR
-
raw_jsonVARCHAR
Read contextual qualifiers attached to Wikidata statements
SELECT statement_property_id, count(*) AS qualifiers
FROM wiki.wikidata.qualifiers(['Q42'])
GROUP BY statement_property_id
ORDER BY statement_property_id;
Each spouse (P26) of Douglas Adams (Q42) with that statement's qualifiers, such as the P580 start time and P582 end time of the marriage
SELECT s.value.entity_id AS spouse, q.property_id AS qualifier,
coalesce(q.value.time, q.value.entity_id) AS qualifier_value
FROM wiki.wikidata.statements(['Q42'], property_id := 'P26') AS s
JOIN wiki.wikidata.qualifiers(['Q42'], property_id := 'P26') AS q USING (source_api, entity_revision, requested_id, statement_id)
ORDER BY spouse, qualifier;
search (query VARCHAR, api_url := VARCHAR, cache_seconds := BIGINT, count := BIGINT, entity_type := VARCHAR, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, timeout_ms := BIGINT)
Search Wikidata labels and aliases
Search Wikidata labels and aliases
SELECT entity_id, label
FROM wiki.wikidata.search('Douglas Adams', count := 3)
ORDER BY entity_id;
sparql (query VARCHAR, cache_seconds := BIGINT, endpoint_url := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, timeout_ms := BIGINT)
Query Wikidata relationships with read-only SPARQL
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
Query Wikidata relationships with read-only SPARQL
SELECT answer
FROM wiki.wikidata.sparql('ASK { <http://www.wikidata.org/entity/Q42> ?p ?o }');
statement_references (ids VARCHAR[], api_url := VARCHAR, cache_seconds := BIGINT, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, property_id := VARCHAR, rank := VARCHAR, timeout_ms := BIGINT)
Read sources attached to Wikidata statements
-
entity_idVARCHAR
-
textVARCHAR
-
languageVARCHAR
-
timeVARCHAR
-
time_precisionINTEGER
-
timezoneINTEGER
-
beforeBIGINT
-
afterBIGINT
-
calendar_modelVARCHAR
-
amountVARCHAR
-
lower_boundVARCHAR
-
upper_boundVARCHAR
-
unitVARCHAR
-
latitudeDOUBLE
-
longitudeDOUBLE
-
coordinate_precisionDOUBLE
-
globeVARCHAR
-
raw_jsonVARCHAR
Read sources attached to Wikidata statements
SELECT statement_property_id, count(*) AS reference_snaks
FROM wiki.wikidata.statement_references(['Q42'])
GROUP BY statement_property_id
ORDER BY statement_property_id;
How many distinct reference groups (sources) back each of Douglas Adams's (Q42) instance-of (P31) statements; statements with no source count 0
SELECT s.statement_id, s.value.entity_id AS class,
count(DISTINCT r.reference_hash) AS sources
FROM wiki.wikidata.statements(['Q42'], property_id := 'P31') AS s
LEFT JOIN wiki.wikidata.statement_references(['Q42'], property_id := 'P31') AS r USING (source_api, entity_revision, requested_id, statement_id)
GROUP BY s.statement_id, class
ORDER BY s.statement_id;
statements (ids VARCHAR[], api_url := VARCHAR, cache_seconds := BIGINT, lang := VARCHAR, max_bytes := BIGINT, max_rows := BIGINT, property_id := VARCHAR, rank := VARCHAR, timeout_ms := BIGINT)
Read full Wikidata statements with typed values
-
entity_idVARCHAR
-
textVARCHAR
-
languageVARCHAR
-
timeVARCHAR
-
time_precisionINTEGER
-
timezoneINTEGER
-
beforeBIGINT
-
afterBIGINT
-
calendar_modelVARCHAR
-
amountVARCHAR
-
lower_boundVARCHAR
-
upper_boundVARCHAR
-
unitVARCHAR
-
latitudeDOUBLE
-
longitudeDOUBLE
-
coordinate_precisionDOUBLE
-
globeVARCHAR
-
raw_jsonVARCHAR
Read full Wikidata statements with typed values
SELECT property_id, count(*) AS statements
FROM wiki.wikidata.statements(['Q42'])
GROUP BY property_id
ORDER BY property_id;
Douglas Adams's (Q42) best-ranked birth/death dates and places (places as item IDs), each labelled with its property's human-readable name by joining statements to the property entities
SELECT p.label AS property,
coalesce(s.value.time, s.value.entity_id) AS value
FROM wiki.wikidata.statements(['Q42'], rank := 'best') AS s
JOIN wiki.wikidata.entity(['P19', 'P20', 'P569', 'P570']) AS p ON s.property_id = p.entity_id
ORDER BY s.property_id;
Try these queries
Fetch the English Wikipedia summary extract for the DuckDB article.
SELECT wiki.main.wiki_page('DuckDB')
Uses wiki_page
Fetch the rich English summary row (title, extract, url) for DuckDB.
SELECT title, extract, url
FROM wiki.main.wiki_page_summary('DuckDB', lang := 'en')
Uses wiki_page_summary
Resolve a Wikipedia article to its Wikidata identity
SELECT title, entity_id
FROM wiki.main.wiki_entity('Douglas Adams')
ORDER BY title
Uses wiki_entity
Follow up to 3 sroffset pages of German results
SELECT title
FROM wiki.main.wiki_search('duckdb', lang := 'de', count := 5, max_pages := 3)
Uses wiki_search
Retrieve Wikidata entities in batches
SELECT entity_id, label
FROM wiki.wikidata.entity(['Q42'])
ORDER BY entity_id
Uses entity
Douglas Adams's (Q42) best-ranked birth/death dates and places (places as item IDs), each labelled with its property's human-readable name by joining statements to the property entities
SELECT p.label AS property,
coalesce(s.value.time, s.value.entity_id) AS value
FROM wiki.wikidata.statements(['Q42'], rank := 'best') AS s
JOIN wiki.wikidata.entity(['P19', 'P20', 'P569', 'P570']) AS p ON s.property_id = p.entity_id
ORDER BY s.property_id
Uses statementsentity
17 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- Using the wiki catalog, fetch the Wikipedia page summary for the article titled 'DuckDB' and return just its resolved page title.
- Using the wiki catalog, return a single boolean that is true when the English Wikipedia article 'DuckDB' has a non-empty summary extract.
- Return the Wikidata ID associated with the English Wikipedia article 'Douglas Adams'.
- Return the English label for Wikidata entity Q42.
- Return Q42's birth-date string from P569, preserving the upstream time representation.
- For Q42's spouse statements (P26), list the distinct qualifier property IDs in property order.
Wikipedia is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Search
News, social & research
Query Brave, Tavily, Exa, SearXNG, DuckDuckGo, SerpAPI and Serper web search from SQL through one interface
Scholar
News, social & research
Search OpenAlex, arXiv, and Crossref for papers from SQL, with one unified result schema
Bluesky
News, social & research
Bluesky posts, threads, profiles, followers, feeds, trends and the live Jetstream firehose