Mediawiki Semantic Query icon

Mediawiki Semantic Query

Execute a Semantic MediaWiki Ask query to retrieve semantic data

Mediawiki Semantic Query

AI-generated

Summary

Runs a Semantic MediaWiki Ask query against a wiki's api.php and returns one n8n item per matching page, with the requested semantic properties flattened into readable values.

Inputs

  • wikiUrl — Overrides the site URL from the mediaWikiApi credentials. '/api.php' is appended unless the URL already ends with it.
  • query (required) — SMW Ask condition string, e.g. [[Category:Person]][[Has job::Developer]]. Supports expressions.
  • fields — Comma-separated property names. Each is added to the query as a printout (|?Property). Values are trimmed and empty entries dropped.
  • limit — Maximum results (1–5000, default 50). Appended as |limit=N.
  • sortOrder — Raw SMW sort/order parameters appended to the query, e.g. 'sort=Has date' or 'order=descending|sort=Has date'.

Output shape

One item per matched wiki page with json {pageTitle, fullUrl, semanticData}. semanticData maps each requested property name to a processed value. Single-value arrays become the value, empty ones become null, and multiple values stay as an array. Dates become {timestamp, formatted (ISO 8601)}, pages become their title text, quantities become the raw value, coordinates become {lat, lon}, and SMW '#0##'-style suffixes are stripped.

If there are no results, one item is returned with {query, resultCount: 0, results: []}. An API error response throws an 'Ask API error'. With Continue On Fail, the node emits {error: message} for that input item instead. The query runs once per input item, and each output is paired to its input item. It requires the mediaWikiApi credential. Only the first batch up to the limit is fetched, with no pagination.

Examples

Example 1: List the 20 most recent articles with their authors and dates

Query: [[Category:Article]]; Fields: Has author, Has date; Limit: 20; Sort Order: order=descending|sort=Has date

Example 2: Find all pages that have a video URL property set

Query: [[A une URL de vidéo::+]]; Fields: A une URL de vidéo; Limit: 500

Links

Discussion