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
  }
  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

Success11.24 s88,385 bytes

Response bytes

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

Showing 5 of 1338 rows.

metaclassmetaclassLabelinstanceCount
http://www.wikidata.org/entity/Q16521taxon3853127
http://www.wikidata.org/entity/Q113145171type of chemical entity1280324
http://www.wikidata.org/entity/Q8054protein1021465
http://www.wikidata.org/entity/Q3331189version, edition or translation857012
http://www.wikidata.org/entity/Q113813711coin type214503

Download results.csv

results.csv

{
  "@context": "https://w3id.org/ro/crate/1.3/context",
  "@graph": [
    {
      "@id": "ro-crate-metadata.json",
      "@type": "CreativeWork",
      "about": {
        "@id": "./"
      },
      "conformsTo": {
        "@id": "https://w3id.org/ro/crate/1.3"
      }
    },
    {
      "@id": "./",
      "@type": "Dataset",
      "additionalProperty": [
        {
          "@id": "#retrieval-duration"
        }
      ],
      "author": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "datePublished": "2026-10-31T11:20:46.303780043+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": "88385",
      "encodingFormat": "text/csv",
      "sha256": "4ae3f55d18cf438d46742cdbb37b02cb44bd550a21665c713d1940d7afb3e220"
    },
    {
      "@id": "query.rq",
      "@type": "File",
      "contentSize": "756",
      "encodingFormat": "application/sparql-query",
      "sha256": "f3557c77790806b0596f657270d920ceedf03359c71d023158f1558b0b38a61c"
    },
    {
      "@id": "https://vitrify.iolanta.tech",
      "@type": "SoftwareApplication",
      "name": "Vitrify",
      "url": "https://vitrify.iolanta.tech",
      "version": "0.1.3"
    },
    {
      "@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-31T11:20:46.303780043+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-31T11:20:35.065299520+00:00"
    },
    {
      "@id": "#retrieval-duration",
      "@type": "PropertyValue",
      "name": "Retrieval duration",
      "propertyID": "retrieval-duration",
      "unitCode": "SEC",
      "value": 11.23745907
    }
  ]
}

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
  }
  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