Skip to content

Metaclasses by instance count

The query ranks metaclasses in Wikidata by their number of distinct direct instance of (P31) statements. Candidates are explicitly typed metaclasses: they have an instance of type equal to metaclass or one of its subclasses, such as second-order class. This follows recorded types, rather than checking that each instance is itself a class. The counts use truthy P31 values and do not include instances inherited through subclasses. Ties are resolved by item URI.

printf '%s' 'PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?metaclass ?metaclassLabel ?instanceCount WHERE {
  {
    SELECT ?metaclass (COUNT(DISTINCT ?instance) AS ?instanceCount) WHERE {
      {
        SELECT DISTINCT ?metaclass WHERE {
          ?metaclass wdt:P31/wdt:P279* wd:Q19478619 .
        }
      }
      ?instance wdt:P31 ?metaclass .
    }
    GROUP BY ?metaclass
    ORDER BY DESC(?instanceCount) ?metaclass
    LIMIT 10
  }
  OPTIONAL {
    ?metaclass rdfs:label ?englishLabel .
    FILTER(LANG(?englishLabel) = "en")
  }
  BIND(COALESCE(?englishLabel, STRAFTER(STR(?metaclass), "entity/")) AS ?metaclassLabel)
}
ORDER BY DESC(?instanceCount) ?metaclass
' |
  vitrify sparql --endpoint https://qlever.dev/api/wikidata \
  --query - \
  --format csv \
  --to top-metaclasses

Success≈ 1.72 s694 bytes

Response bytes

top-metaclasses/
├── results.csv
├── ro-crate-metadata.json
└── query.rq

Showing 5 of 10 rows.

metaclassmetaclassLabelinstanceCount
http://www.wikidata.org/entity/Q16521taxon3851552
http://www.wikidata.org/entity/Q113145171type of chemical entity1280299
http://www.wikidata.org/entity/Q8054protein1021037
http://www.wikidata.org/entity/Q3331189version, edition or translation852704
http://www.wikidata.org/entity/Q113813711coin type214462

Download results.csv

results.csv

{
  "@context": "https://w3id.org/ro/crate/1.2/context",
  "@graph": [
    {
      "@id": "ro-crate-metadata.json",
      "@type": "CreativeWork",
      "about": {
        "@id": "./"
      },
      "conformsTo": {
        "@id": "https://w3id.org/ro/crate/1.2"
      }
    },
    {
      "@id": "./",
      "@type": "Dataset",
      "author": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "datePublished": "2026-10-10T10:54:46.387312636+00:00",
      "description": "SPARQL retrieval materialized by Vitrify.",
      "hasPart": [
        {
          "@id": "results.csv"
        },
        {
          "@id": "query.rq"
        }
      ],
      "license": "No license asserted by Vitrify; consult the source endpoint's terms of use.",
      "name": "results.csv",
      "publisher": {
        "@id": "https://qlever.dev/api/wikidata"
      }
    },
    {
      "@id": "results.csv",
      "@type": "File",
      "contentSize": "694",
      "encodingFormat": "text/csv",
      "sha256": "0b6f7c6aa1861209643fcfebc5c536be466c83b31acc3d394ff4b6746e1b418d"
    },
    {
      "@id": "query.rq",
      "@type": "File",
      "contentSize": "769",
      "encodingFormat": "application/sparql-query",
      "sha256": "9b4c71804c7808c756426df34128eb32b4b7ea3ebaae78426c02680820280f23"
    },
    {
      "@id": "https://vitrify.iolanta.tech",
      "@type": "SoftwareApplication",
      "name": "Vitrify",
      "url": "https://vitrify.iolanta.tech",
      "version": "0.1.0"
    },
    {
      "@id": "https://qlever.dev/api/wikidata",
      "@type": "Organization"
    },
    {
      "@id": "#retrieval",
      "@type": "CreateAction",
      "agent": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "description": "HTTP 200; Accept: text/csv",
      "endTime": "2026-10-10T10:54:46.387312636+00:00",
      "identifier": "https://qlever.dev/api/wikidata",
      "instrument": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "object": [
        {
          "@id": "https://qlever.dev/api/wikidata"
        },
        {
          "@id": "query.rq"
        }
      ],
      "result": {
        "@id": "results.csv"
      },
      "startTime": "2026-10-10T10:54:44.667867565+00:00"
    }
  ]
}

Download ro-crate-metadata.json

ro-crate-metadata.json

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?metaclass ?metaclassLabel ?instanceCount WHERE {
  {
    SELECT ?metaclass (COUNT(DISTINCT ?instance) AS ?instanceCount) WHERE {
      {
        SELECT DISTINCT ?metaclass WHERE {
          ?metaclass wdt:P31/wdt:P279* wd:Q19478619 .
        }
      }
      ?instance wdt:P31 ?metaclass .
    }
    GROUP BY ?metaclass
    ORDER BY DESC(?instanceCount) ?metaclass
    LIMIT 10
  }
  OPTIONAL {
    ?metaclass rdfs:label ?englishLabel .
    FILTER(LANG(?englishLabel) = "en")
  }
  BIND(COALESCE(?englishLabel, STRAFTER(STR(?metaclass), "entity/")) AS ?metaclassLabel)
}
ORDER BY DESC(?instanceCount) ?metaclass

Download query.rq

query.rq