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

Success0.84 s717 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-12T15:30:19.526699673+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": "717",
      "sha256": "12118a1bfd5e7869f55392536bbc31b79d8baccb2017d3490464284f07950c9a",
      "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-12T15:30:18.676448689+00:00",
      "endTime": "2026-11-12T15:30:19.526699673+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": 0.838436473,
      "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