Wikimedia Petscan logo

Wikimedia Petscan

Community
fuzheado
wikimedia-petscan

Use PetScan for multi-source Wikimedia queries — category intersections, template filtering, SPARQL integration, Wikidata item queries, and bulk data export via the URL API and PSID system

Overview

Publisherfuzheado
RepositoryWikipedia-AI-Skills
Skill namewikimedia-petscan
Stars
27
Forks
10
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by fuzheado on GitHub. Read the source before you install it.

Installation

Install the Wikimedia Petscan AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-petscan
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikimedia-petscan .claude/skills/wikimedia-petscan
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Wikimedia Petscan in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Wikimedia Petscan on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Wikimedia Petscan is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

ℹ️ User-Agent required: All API examples in this skill access PetScan (petscan.wmcloud.org). Include a descriptive User-Agent header as described in the wikimedia-api-access skill.

💡 Related skills for complementary query approaches:


SOP: What PetScan Is

PetScan is a powerful multi-source querying tool for Wikimedia, created by Magnus Manske as the successor to CatScan2. Winner of the Coolest Tool Award 2022.

It generates lists of pages or Wikidata items matching criteria across up to 6 source tabs simultaneously:

TabWhat it queriesExample
CategoriesCategory tree membership, intersection/union/differencePages in Category:Physics AND Category:Biography
Page propertiesNamespace, redirects, size, dates, edit types, ORES qualityFiles only, created after 2024, not redirects
Templates & linksTemplate presence, outlinks, incoming linksPages with {{Infobox scientist}} but NOT {{Unreferenced}}
Other sourcesSPARQL, manual list, PagePile, search queryAll QIDs from a SPARQL query, minus a manual exclusion list
WikidataWikidata item filters — statements, properties, sitelinks, labelsItems with an occupation but no image
OutputFormat, sorting, regex filter, file media typesJSON sorted by page size, with regex filter on title

The key insight: PetScan combines these sources into one result using configurable logic (subset/union/difference/at-least-N). You can mix categories with SPARQL, templates with manual lists, etc. — including cross-wiki via Wikidata.

Three Ways to Use PetScan

MethodWhenHow
Web UIOne-off queries, explorationhttps://petscan.wmcloud.org/ — fill forms, tabs, click "Do it!"
URL APIAutomation, scriptsAppend URL parameters to the base URL, get JSON/CSV/XML/...
PSIDShare, rerun, tool integrationEvery query gets a stable ID; ?psid=12345 re-runs it

SOP: PSID — Stable Query IDs

Since 2016, every submitted PetScan query is assigned a unique, stable numeric PSID (displayed in the result page). This enables:

  • Short URLs: https://petscan.wmcloud.org/?psid=552
  • Re-running queries without re-entering all parameters
  • Tool integration: Many tools (WD-FIST, PagePile, Massviews) accept PSID as input
  • Caching: PSID results are cached server-side for faster repeat access

PSIDs are anonymous — no user identity is stored with them.


SOP: URL Parameter Reference

PetScan accepts 50+ URL parameters across all six tabs. Here are the most commonly used ones in automation:

Categories Tab

ParameterDescription
languageWiki language code (en, de, commons, etc.)
projectWikimedia project (wikipedia, wiktionary, commons, wikidata)
categoriesPipe-separated category names (no Category: prefix). Append `
depthDefault category tree depth (0 = no recursion)
combinationsubset (AND — all categories), union (OR — any category)
negcatsPipe-separated categories to exclude

Page Properties Tab

ParameterDescription
ns[0], ns[6], etc.Namespace filter (set to 1 to include)
show_redirectsno (default), only, yes (include redirects)
show_soft_redirectsSame options for soft redirects
show_disambiguation_pagesSame options for disambiguation pages
after, beforeDate filter (YYYYMMDDHHMMSS format)
since_rev0Find pages created within a time window
larger, smallerPage size range in bytes
minlinks, maxlinksInternal link count range
edits[bots], edits[anons]Filter by last editor type (1 to require, 0 to exclude)
ores_predictionORES quality class (FA, GA, B, C, Start, Stub)
ores_prob_from, ores_prob_toORES probability range

Templates & Links Tab

ParameterDescription
templates_yesPipe-separated templates — page must have ALL of them
templates_anyPipe-separated templates — page must have at least ONE
templates_noPipe-separated templates — page must have NONE
outlinks_yes, outlinks_any, outlinks_noSame pattern for outgoing links
links_to_all, links_to_any, links_to_noSame pattern for incoming links

Other Sources Tab

ParameterDescription
sparqlRaw SPARQL query (URL-encoded) as a data source
manual_listNewline-separated page titles or QIDs
manual_list_wikiWiki for the manual list (e.g., enwiki, wikidatawiki)
pagepilePagePile ID
search_queryFree-text search query
search_max_resultsMax results from search source
source_combinationHow to combine sources: subset, union, or custom (e.g., manual NOT sparql)

Wikidata Tab

ParameterDescription
wikidata_itemwith, without, or any — whether items have a Wikidata ID
wikidata_source_sitesWiki to use as source for site links
wikidata_label_languageLanguage for labels in results
wpiuWikidata property item use filter
sitelinks_yes, sitelinks_any, sitelinks_noFilter by sitelink presence on specific wikis
labels_yes, labels_any, labels_noFilter by label presence in specific languages
min_sitelink_count, max_sitelink_countSitelink count range

Output Tab

ParameterDescription
formathtml, csv, tsv, wiki, json, jsonl, pagepile, kml, plain
sortbynone, title, size, date, incoming_links, random, etc.
sortorderascending or descending
output_limitMaximum number of results
rxp_filterRegular expression to filter titles/labels
file_media_typesPipe-separated media types (BITMAP, VIDEO, AUDIO, 3D, etc.)
page_imageInclude page image URL in output
json-prettyPretty-printed JSON (1)

SOP: Common API Patterns

All examples use curl. Replace language/project as needed.

Category Intersection (AND)

Pages in ALL categories — equivalent to category-intersect.py in the wikipedia-categories skill:

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=en\
  &project=wikipedia\
  &categories=Physicists%7CGerman%20scientists\
  &ns%5B0%5D=1\
  &combination=subset\
  &format=json' \
  -H 'User-Agent: MyTool/1.0 (contact@example.com)'

Category + Template Filter

Pages in Category:Physics that have {{WikiProject Physics}}:

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=en\
  &project=wikipedia\
  &categories=Physics\
  &templates_yes=WikiProject%20Physics\
  &ns%5B0%5D=1\
  &format=json' \
  -H 'User-Agent: ...'

Category + ORES Quality Filter

FA-class articles in a category:

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=en\
  &project=wikipedia\
  &categories=Physics\
  &ores_prediction=FA\
  &ns%5B0%5D=1\
  &format=json' \
  -H 'User-Agent: ...'

SPARQL as a Data Source

Get all items from a SPARQL query that are also in a category:

bash
SPARQL_ENC=$(python3 -c "import urllib.parse; print(urllib.parse.quote(\"\"\"\
SELECT ?item WHERE { ?item wdt:P31 wd:Q5 ; wdt:P106 wd:Q2519376 }
\"\"\"))")
curl -s "https://petscan.wmcloud.org/\
  ?language=en\
  &project=wikipedia\
  &categories=American%20jewellers\
  &sparql=$SPARQL_ENC\
  &combination=subset\
  &format=json" \
  -H 'User-Agent: ...'

Manual List + SPARQL Exclusion

QIDs from a manual list, minus those that already have a certain occupation:

bash
MANUAL="Q123\nQ456\nQ789"
MANUAL_ENC=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$MANUAL'''))")
SPARQL_EXCLUDE=$(python3 -c "import urllib.parse; print(urllib.parse.quote(\"\"\"\
SELECT ?item WHERE { ?item wdt:P31 wd:Q5 ; wdt:P106 wd:Q2519376 }\
\"\"\"))")
curl -s "https://petscan.wmcloud.org/\
  ?manual_list=$MANUAL_ENC\
  &manual_list_wiki=wikidatawiki\
  &sparql=$SPARQL_EXCLUDE\
  &source_combination=manual%20NOT%20sparql\
  &format=json" \
  -H 'User-Agent: ...'

Items Without Wikidata Statements (Data Quality)

Find English Wikipedia articles in a category that have a Wikidata item but no statements:

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=en\
  &project=wikipedia\
  &categories=United%20States%20geography%20stubs\
  &ns%5B0%5D=1\
  &wikidata_item=with\
  &wpiu_no_statements=1\
  &format=json' \
  -H 'User-Agent: ...'

Commons: Find Uncategorized Files with a Language Template

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=commons\
  &project=wikimedia\
  &categories=Uncategorized%20files\
  &depth=1\
  &ns%5B6%5D=1\
  &templates_yes=ro\
  &format=json' \
  -H 'User-Agent: ...'

PSID-Based Query

Re-run a previously saved query:

bash
curl -s 'https://petscan.wmcloud.org/?psid=552&format=json' \
  -H 'User-Agent: ...'

Output as Wiki Table

Any format parameter changes the output:

bash
curl -s 'https://petscan.wmcloud.org/\
  ?language=en&project=wikipedia&categories=Physics\
  &ns%5B0%5D=1&format=wiki' \
  -H 'User-Agent: ...'

SOP: Multi-Source Combination Logic

When using multiple sources (categories + SPARQL + manual list + pagepile + search), the combination parameter controls how they are merged. With source_combination, you get more control:

ValueEffect
subset (default)Return only results present in ALL sources (AND)
unionReturn results from ANY source (OR)
source1 NOT source2Results from first source minus second
source1 AND source2Explicit AND between named sources

Sources are ordered as: categories → manual_list → pagepile → sparql → search. Use source_combination to reorder or mix.

Cross-wiki magic: Use common_wiki=wikidata to merge results across different wikis. PetScan will resolve pages from different wikis through Wikidata to find common items.


SOP: Integration with Other Tools

ToolHow PetScan Feeds Into It
PagePileOutput format pagepile creates a new PagePile; or feed PSID into PagePile's "from external tool" field
Massviews AnalysisUse PagePile ID from PetScan as source → get pageviews for the query result set
WD-FISTPSID → find free images for a list of articles
QuickStatementsExport as JSON/CSV, transform to QuickStatements format

Relationship to Other Skills

  • wikipedia-categories — Covers category tree concepts and ships category-intersect.py (uses PetScan's URL API for basic AND intersection). This skill covers the full parameter surface PetScan offers.
  • wikimedia-search-cirrussearch — CirrusSearch is faster for simple keyword+category. PetScan is the right choice when you need category intersection/union/difference, multi-source combination (categories + templates + SPARQL), ORES filtering, or bulk export. See the comparison table in that skill.
  • wikidata — For complex SPARQL queries that exceed PetScan's single-query input, use the Wikidata Query Service directly.
  • wikimedia-commons-sparql — For Commons-specific MediaInfo queries; PetScan complements with file media type filtering and uncategorized file detection.

Frequently asked questions

What does the Wikimedia Petscan AI skill do?

Use PetScan for multi-source Wikimedia queries — category intersections, template filtering, SPARQL integration, Wikidata item queries, and bulk data export via the URL API and PSID system

Why use Wikimedia Petscan on TypingMind?

Because you install it once and use it with any model. Wikimedia Petscan is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Wikimedia Petscan in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-petscan. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Wikimedia Petscan?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Wikimedia Petscan?

As many as you like. As long as a model supports skills, you can use Wikimedia Petscan with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Wikimedia Petscan AI skill free?

Yes. It is published on GitHub by fuzheado under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇