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
Success2.80 s694 bytes
Response bytes
top-metaclasses/
├── results.csv
├── ro-crate-metadata.json
└── query.rq
Showing 5 of 10 rows.
| metaclass | metaclassLabel | instanceCount |
|---|---|---|
| http://www.wikidata.org/entity/Q16521 | taxon | 3851902 |
| http://www.wikidata.org/entity/Q113145171 | type of chemical entity | 1280306 |
| http://www.wikidata.org/entity/Q8054 | protein | 1021038 |
| http://www.wikidata.org/entity/Q3331189 | version, edition or translation | 853708 |
| http://www.wikidata.org/entity/Q113813711 | coin type | 214464 |
{
"@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",
"additionalProperty": [
{
"@id": "#retrieval-duration"
}
],
"author": {
"@id": "https://vitrify.iolanta.tech"
},
"datePublished": "2026-10-16T10:06:32.484064725+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",
"additionalProperty": [
{
"@id": "#row-count"
}
],
"contentSize": "694",
"encodingFormat": "text/csv",
"sha256": "e93e0c18b0ba9ca6ead1b6f3ba98026d21abcd4c5579fcee47bacc27a40086e6"
},
{
"@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.2"
},
{
"@id": "https://qlever.dev/api/wikidata",
"@type": "Organization"
},
{
"@id": "#retrieval",
"@type": "CreateAction",
"actionStatus": {
"@id": "http://schema.org/CompletedActionStatus"
},
"agent": {
"@id": "https://vitrify.iolanta.tech"
},
"description": "HTTP 200; Accept: text/csv",
"endTime": "2026-10-16T10:06:32.484064725+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-16T10:06:29.669451532+00:00"
},
{
"@id": "#retrieval-duration",
"@type": "PropertyValue",
"name": "Retrieval duration",
"propertyID": "retrieval-duration",
"unitCode": "SEC",
"value": 2.80197581
},
{
"@id": "#row-count",
"@type": "PropertyValue",
"name": "Row count",
"propertyID": "row-count",
"unitText": "rows",
"value": 12
}
]
}
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