Third-order classes
The query lists all items in Wikidata whose recorded
instance of (P31) type is
third-order class or a subclass
of that type, ordered by English label and item URI. A third-order class has
second-order classes as its instances. This query selects recorded types;
it does not check the order of every instance.
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 DISTINCT ?class ?classLabel WHERE {
?class wdt:P31/wdt:P279* wd:Q24017465 .
OPTIONAL {
?class rdfs:label ?englishLabel .
FILTER(LANG(?englishLabel) = "en")
}
BIND(COALESCE(?englishLabel, STRAFTER(STR(?class), "entity/")) AS ?classLabel)
}
ORDER BY ?classLabel ?class
' |
vitrify sparql --endpoint https://query.wikidata.org/sparql \
--query - \
--format csv \
--to third-order-classes
Success3.61 s797 bytes
Response bytes
third-order-classes/
├── results.csv
├── ro-crate-metadata.json
└── query.rq
Showing 5 of 12 rows.
| class | classLabel |
|---|---|
| http://www.wikidata.org/entity/Q94945104 | anatomical metaclass |
| http://www.wikidata.org/entity/Q103997018 | direct anatomical metaclass |
| http://www.wikidata.org/entity/Q103997133 | indirect anatomical metaclass |
| http://www.wikidata.org/entity/Q103994247 | medical metaclass |
| http://www.wikidata.org/entity/Q29918297 | metaclass of ambassadors |
{
"@context": "https://w3id.org/ro/crate/1.3/context",
"@graph": [
{
"@id": "ro-crate-metadata.json",
"@type": "CreativeWork",
"conformsTo": {
"@id": "https://w3id.org/ro/crate/1.3"
},
"about": {
"@id": "./"
}
},
{
"@id": "./",
"@type": "Dataset",
"name": "results.csv",
"description": "SPARQL retrieval materialized by Vitrify.",
"datePublished": "2026-11-21T12:01:45.991434942+00:00",
"additionalProperty": [
{
"@id": "#retrieval-duration"
}
],
"license": "No license asserted by Vitrify; consult the source endpoint's terms of use.",
"hasPart": [
{
"@id": "results.csv"
},
{
"@id": "query.rq"
}
],
"publisher": {
"@id": "https://query.wikidata.org/sparql"
},
"author": {
"@id": "https://vitrify.iolanta.tech"
}
},
{
"@id": "results.csv",
"@type": "File",
"contentSize": "797",
"sha256": "2370e25bf0284209561137dee9cfc21711011df90bb85eb5c533a5798ac3f532",
"encodingFormat": "text/csv"
},
{
"@id": "query.rq",
"@type": "File",
"contentSize": "440",
"encodingFormat": "application/sparql-query",
"sha256": "30904465b228f4ac14afd0b529b56de51976e7656d7c510c2fc9aba66180bab0"
},
{
"@id": "https://vitrify.iolanta.tech",
"@type": "SoftwareApplication",
"name": "Vitrify",
"url": "https://vitrify.iolanta.tech",
"version": "0.1.4"
},
{
"@id": "https://query.wikidata.org/sparql",
"@type": "Organization"
},
{
"@id": "#retrieval",
"@type": "CreateAction",
"actionStatus": {
"@id": "http://schema.org/CompletedActionStatus"
},
"startTime": "2026-11-21T12:01:42.377829379+00:00",
"endTime": "2026-11-21T12:01:45.991434942+00:00",
"instrument": {
"@id": "https://vitrify.iolanta.tech"
},
"agent": {
"@id": "https://vitrify.iolanta.tech"
},
"object": [
{
"@id": "https://query.wikidata.org/sparql"
},
{
"@id": "query.rq"
}
],
"result": {
"@id": "results.csv"
},
"identifier": "https://query.wikidata.org/sparql",
"description": "HTTP 200; Accept: text/csv"
},
{
"@id": "#retrieval-duration",
"@type": "PropertyValue",
"propertyID": "retrieval-duration",
"name": "Retrieval duration",
"value": 3.610923188,
"unitCode": "SEC"
}
]
}
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 DISTINCT ?class ?classLabel WHERE {
?class wdt:P31/wdt:P279* wd:Q24017465 .
OPTIONAL {
?class rdfs:label ?englishLabel .
FILTER(LANG(?englishLabel) = "en")
}
BIND(COALESCE(?englishLabel, STRAFTER(STR(?class), "entity/")) AS ?classLabel)
}
ORDER BY ?classLabel ?class