ParseForge Scrapers

Wikimedia Commons Category Hierarchy Scraper

parseforge/wikimedia-commons-category-scraper

OtherAIDeveloper tools

Recursively scrapes Wikimedia Commons category trees from a start category. Returns parent-child relationships with page IDs and namespaces for building taxonomies or knowledge graphs.

Run this scraper See the API call
Total runs
3
Bookmarked
0
Last modified
21 hours ago

This scraper was last updated on .

What does the Wikimedia Commons Category Hierarchy Scraper return?

ParseForge

Wikimedia Commons Category Hierarchy Scraper

Scrape the Wikimedia Commons category hierarchy from any starting category, up to 10 levels deep. Extract every subcategory title, page ID, and namespace, and reconstruct the full tree structure. Export to CSV, JSON, Excel, or XML.

Wikimedia Commons holds millions of freely licensed media files, organized across a large category tree. Manually navigating or mapping this hierarchy is slow and impractical. This Actor queries the official Wikimedia API to recursively extract category structures, giving you a clean dataset of parent-child relationships without writing a script.

Who uses it What they scrape Wikimedia Commons for
Digital archivists Mapping the organizational structure of a public domain media collection.
Data scientists Building a knowledge graph or taxonomy from Wikimedia Commons category relationships.
SEO analysts Understanding how a large media repository categorizes topics for content strategy.
Researchers Analyzing the distribution and depth of categories within a specific domain.

What it does

This Actor collects Wikimedia Commons subcategory titles and IDs from a starting category, recursively traversing the tree up to a specified depth, and returns each category relationship as a flat row.

  • Recursive tree traversal: Start from any category and drill down through multiple levels of subcategories.
  • Configurable depth limit: Control how deep the scraper goes, from a single level of children up to 10 levels.
  • Structured output: Each row captures a parent category, its child subcategory, page ID, and namespace.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

What you can do with Wikimedia Commons data

Map a media collection's structure.

A digital archivist starts from 'Category:Photographs by topic' and extracts the full subcategory tree to understand how millions of images are organized.

Build a training taxonomy.

A machine learning engineer scrapes the category hierarchy under 'Category:Animals' to create a labeled dataset for hierarchical classification models.

Audit category coverage.

An SEO analyst extracts the subcategories of 'Category:Diagrams' to identify content gaps and plan new visual assets for a website.

Why choose this scraper

What you get
Official API access Reads directly from the public Wikimedia API with no authentication or API key required.
Recursive extraction Automatically follows subcategory links to build a complete hierarchy from your chosen root.
Clean relational output Returns parent-child pairs ready to import into graph databases or taxonomy tools.

What a Wikimedia Commons record looks like

Every record returns as one flat JSON row. Here is a real one from a run:

{
 "pageid": 198793313,
 "ns": 14,
 "title": "Category:Categories by former function",
 "depth": 1,
 "parentTitle": "Category:Categories",
 "scrapedAt": "2026-09-04T00:45:59.430Z"
}

Every value above comes from a real run. A field a record does not have comes back as null.

Configure the run

Drive the Actor by providing a single start category title, and set the maximum recursion depth to control how far down the tree it traverses. The Input tab lists every parameter.

A first run with the defaults:

{
 "startCategory": "Category:Categories",
 "maxDepth": 2,
 "maxItems": 10
}

A larger pull:

{
 "startCategory": "Category:Categories",
 "maxDepth": 2,
 "maxItems": 200
}

Free users

Free-plan runs return up to 10 results as a preview. Upgrade your Apify plan to collect up to 1,000,000 results per run.

Run it

  1. Create a free Apify account.
  2. Open the Wikimedia Commons Category Hierarchy Scraper.
  3. Set your inputs and any filters, then click Start.
  4. Export the results as CSV, Excel, JSON, or XML from the Dataset tab.

Run it programmatically through the Apify API (run-sync-get-dataset-items) or the ApifyClient for JavaScript and Python.

Use with AI agents (MCP)

Give an AI agent live access to Wikimedia Commons through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

claude mcp add --transport http apify "https://mcp.apify.com?tools=parseforge/wikimedia-commons-category-scraper"

Then prompt it in plain language to run the scraper and read back the results.

Troubleshooting

Why am I getting no results?

Check that your start category title includes the exact 'Category:' prefix and matches an existing category on Wikimedia Commons. Also verify that the category contains subcategories; some leaf categories have none.

The run is taking too long or timing out.

Large category trees can take time to traverse. Reduce the maxDepth setting to limit how many levels the Actor follows, or lower the maxItems count to stop after a certain number of results.

I see duplicate rows in my output.

A subcategory can belong to multiple parent categories on Wikimedia Commons. The Actor records each parent-child relationship it finds, which may result in the same child appearing under different parents. This reflects the real category structure.

The scraper stopped before reaching the maxDepth I set.

The Actor respects the maxItems limit first. If it reaches the maximum number of items before exhausting the depth, it will stop. Increase the maxItems value to allow deeper traversal.

FAQ

Question Answer
Do I need a Wikimedia account or API key to use this scraper? No. The Actor uses the public, unauthenticated Wikimedia API, so no login, account, or API key is required.
How many levels of subcategories can I scrape? You can set the maximum recursion depth from 1 up to 10. A depth of 1 returns only the direct children of your start category, while higher values traverse deeper into the tree.
What format is the output data in? The dataset is returned as a flat table with parent and child category information. You can export it in CSV, JSON, Excel, or XML formats from the Apify platform.
Can I start from any Wikimedia Commons category? Yes. Provide the full category title including the 'Category:' prefix, such as 'Category:Cities' or 'Category:Paintings', and the Actor will begin traversal from there.
Does this scraper download the actual media files? No. This Actor extracts only the category hierarchy metadata, such as titles and IDs. It does not download images, videos, or other media files.
How is the category hierarchy represented in the output? Each row represents a parent-child relationship between two categories, along with the child's page ID and namespace. You can reconstruct the full tree from these pairs.
Is there a limit to how many categories I can scrape? Free users are limited to a preview of 10 items. Paid users can scrape up to 1,000,000 items per run, which is sufficient for very large category trees.
What is the 'namespace' field in the results? The namespace indicates the type of page. For categories, this is typically 14. It helps you distinguish categories from other page types that might appear in the results.

๐Ÿ†˜ Need help? Email parseforge@protonmail.com with your run ID, your input, and what you expected.

What input does the Wikimedia Commons Category Hierarchy Scraper accept?

FieldTypeWhat it doesDefault
startCategory string The full title of the Wikimedia Commons category to start from, including the 'Category:' prefix. For example, 'Category:Categories' to get the top-level category tree. Category:Categories
maxDepth integer How many levels of subcategories to traverse. A value of 1 returns only direct children of the start category. Higher values build a deeper hierarchy. 2
maxItems integer Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000 10

How much does the Wikimedia Commons Category Hierarchy Scraper cost?

from $3.62 per 1,000 results

Charged forWhat it isPrice each
result Single result in the default dataset. $0.00362 to $0.004

Tiered: the lower figure is the price on a higher Apify plan. Billing and the free credit live on Apify.

How do I call the Wikimedia Commons Category Hierarchy Scraper API?

One POST returns the dataset directly. Same shape for every scraper in the library, so swapping the slug is the only change.

POST ยท run and get results
curl -X POST "https://api.apify.com/v2/acts/parseforge~wikimedia-commons-category-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startCategory": "Category:Categories",
    "maxDepth": 2,
    "maxItems": 10
  }'

What example inputs can I use?

Use these inputs to see how a run is configured.

input.json
{
  "startCategory": "Category:Categories",
  "maxDepth": 2,
  "maxItems": 10
}

What do users say about the Wikimedia Commons Category Hierarchy Scraper?

No reviews yet. Be the first.

How do I report an issue with the Wikimedia Commons Category Hierarchy Scraper?

We build and maintain this scraper, so a problem with it comes to us. Report it on the Apify listing and the thread stays attached to the scraper where the next person can find it: open an issue.

Broken and urgent, or you would rather not post in public? Write to parseforge@protonmail.com and it reaches the people who wrote it.

What related scrapers can I use?

Run Wikimedia Commons Category Hierarchy Scraper on Apify All scrapers