Fourth-order classes
The query lists all items in Wikidata whose recorded
instance of (P31) type is
fourth-order class or a subclass
of that type, ordered by English label and item URI. A fourth-order class has
third-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:Q24027474 .
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://qlever.dev/api/wikidata \
--query - \
--format csv \
--to fourth-order-classes
Failure0.39 s
Response bytes
fourth-order-classes/
├── ro-crate-metadata.json
└── query.rq
Failure
endpoint returned HTTP 502 Bad Gateway
{
"@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": "query.rq",
"@type": "File",
"contentSize": "440",
"encodingFormat": "application/sparql-query",
"sha256": "ed05d8a1f14015499577c2472b7373cf251d61d1e64ee9e226771962883f6022"
},
{
"@id": "https://qlever.dev/api/wikidata",
"@type": "Organization"
},
{
"@id": "https://vitrify.iolanta.tech",
"@type": "SoftwareApplication",
"name": "Vitrify",
"url": "https://vitrify.iolanta.tech",
"version": "0.1.2"
},
{
"@id": "#retrieval-duration",
"@type": "PropertyValue",
"name": "Retrieval duration",
"propertyID": "retrieval-duration",
"unitCode": "SEC",
"value": 0.389166384
},
{
"@id": "#error",
"@type": "Thing",
"description": "endpoint returned HTTP 502 Bad Gateway"
},
{
"@id": "./",
"@type": "Dataset",
"additionalProperty": [
{
"@id": "#retrieval-duration"
}
],
"datePublished": "2026-10-30T17:48:51.482509981+00:00",
"description": "SPARQL retrieval recorded by Vitrify.",
"hasPart": [
{
"@id": "query.rq"
}
],
"license": "No license asserted by Vitrify; consult the source endpoint's terms of use.",
"name": "SPARQL retrieval",
"publisher": {
"@id": "https://qlever.dev/api/wikidata"
}
},
{
"@id": "#retrieval",
"@type": "CreateAction",
"actionStatus": {
"@id": "http://schema.org/FailedActionStatus"
},
"agent": {
"@id": "https://vitrify.iolanta.tech"
},
"description": "HTTP 502; Accept: text/csv",
"endTime": "2026-10-30T17:48:51.482509981+00:00",
"error": {
"@id": "#error"
},
"identifier": "https://qlever.dev/api/wikidata",
"instrument": {
"@id": "https://vitrify.iolanta.tech"
},
"object": [
{
"@id": "https://qlever.dev/api/wikidata"
},
{
"@id": "query.rq"
}
],
"startTime": "2026-10-30T17:48:51.081592274+00:00"
}
]
}
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:Q24027474 .
OPTIONAL {
?class rdfs:label ?englishLabel .
FILTER(LANG(?englishLabel) = "en")
}
BIND(COALESCE(?englishLabel, STRAFTER(STR(?class), "entity/")) AS ?classLabel)
}
ORDER BY ?classLabel ?class