Skip to content

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://qlever.dev/api/wikidata \
  --query - \
  --format csv \
  --to third-order-classes

Success1.03 s705 bytes

Response bytes

third-order-classes/
├── results.csv
├── ro-crate-metadata.json
└── query.rq

Showing 5 of 11 rows.

classclassLabel
http://www.wikidata.org/entity/Q94945104anatomical metaclass
http://www.wikidata.org/entity/Q103997018direct anatomical metaclass
http://www.wikidata.org/entity/Q103997133indirect anatomical metaclass
http://www.wikidata.org/entity/Q103994247medical metaclass
http://www.wikidata.org/entity/Q29918297metaclass of ambassadors

Download results.csv

results.csv

{
  "@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-14T11:13:17.285413284+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://qlever.dev/api/wikidata"
      },
      "author": {
        "@id": "https://vitrify.iolanta.tech"
      }
    },
    {
      "@id": "results.csv",
      "@type": "File",
      "contentSize": "705",
      "sha256": "6a7f8d90ca404d7c9a84866f8dea013b74bc40fd4fa8a5dbddc61c562ad10ade",
      "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://qlever.dev/api/wikidata",
      "@type": "Organization"
    },
    {
      "@id": "#retrieval",
      "@type": "CreateAction",
      "actionStatus": {
        "@id": "http://schema.org/CompletedActionStatus"
      },
      "startTime": "2026-11-14T11:13:16.252863781+00:00",
      "endTime": "2026-11-14T11:13:17.285413284+00:00",
      "instrument": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "agent": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "object": [
        {
          "@id": "https://qlever.dev/api/wikidata"
        },
        {
          "@id": "query.rq"
        }
      ],
      "result": {
        "@id": "results.csv"
      },
      "identifier": "https://qlever.dev/api/wikidata",
      "description": "HTTP 200; Accept: text/csv"
    },
    {
      "@id": "#retrieval-duration",
      "@type": "PropertyValue",
      "propertyID": "retrieval-duration",
      "name": "Retrieval duration",
      "value": 1.031235836,
      "unitCode": "SEC"
    }
  ]
}

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

Download query.rq

query.rq