Skip to content

Time-bounded subclasses

This Wikidata query finds subclass statements with start and end qualifiers, then returns their English labels as SPARQL Results JSON.

printf '%s' 'PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?subclass ?subclassName ?superclass ?superclassName ?start ?end WHERE {
  ?subclass p:P279 ?subclassStatement .
  ?subclassStatement ps:P279 ?superclass ;
                     pq:P580 ?start ;
                     pq:P582 ?end .

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q22938576 .   # not a race (competition)
  }

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q3139516 .  # not an abbot or other church official
  }

  ?subclass rdfs:label ?subclassName .
  ?superclass rdfs:label ?superclassName .
  FILTER(LANG(?subclassName) = "en")
  FILTER(LANG(?superclassName) = "en")
}
ORDER BY ?subclassName ?start ?end
' |
  vitrify sparql --endpoint https://query.wikidata.org/sparql \
  --query - \
  --format json \
  --to time-bounded-subclasses

Failure10.21 s

Response bytes

time-bounded-subclasses/
├── ro-crate-metadata.json
└── query.rq

Failure

endpoint returned HTTP 502 Bad Gateway

{
  "@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": "query.rq",
      "@type": "File",
      "encodingFormat": "application/sparql-query",
      "contentSize": "956",
      "sha256": "a6e850963ada0b9f0c8ce793c71525aec94fc29cce48dc656310dd4695900575"
    },
    {
      "@id": "https://query.wikidata.org/sparql",
      "@type": "Organization"
    },
    {
      "@id": "https://vitrify.iolanta.tech",
      "@type": "SoftwareApplication",
      "name": "Vitrify",
      "url": "https://vitrify.iolanta.tech",
      "version": "0.1.4"
    },
    {
      "@id": "#retrieval-duration",
      "@type": "PropertyValue",
      "propertyID": "retrieval-duration",
      "name": "Retrieval duration",
      "value": 10.213877598,
      "unitCode": "SEC"
    },
    {
      "@id": "#error",
      "@type": "Thing",
      "description": "endpoint returned HTTP 502 Bad Gateway"
    },
    {
      "@id": "./",
      "@type": "Dataset",
      "name": "SPARQL retrieval",
      "description": "SPARQL retrieval recorded by Vitrify.",
      "datePublished": "2026-11-28T12:41:34.597018940+00:00",
      "license": "No license asserted by Vitrify; consult the source endpoint's terms of use.",
      "publisher": {
        "@id": "https://query.wikidata.org/sparql"
      },
      "hasPart": [
        {
          "@id": "query.rq"
        }
      ],
      "additionalProperty": [
        {
          "@id": "#retrieval-duration"
        }
      ]
    },
    {
      "@id": "#retrieval",
      "@type": "CreateAction",
      "actionStatus": {
        "@id": "http://schema.org/FailedActionStatus"
      },
      "startTime": "2026-11-28T12:41:24.382028940+00:00",
      "instrument": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "agent": {
        "@id": "https://vitrify.iolanta.tech"
      },
      "object": [
        {
          "@id": "https://query.wikidata.org/sparql"
        },
        {
          "@id": "query.rq"
        }
      ],
      "identifier": "https://query.wikidata.org/sparql",
      "description": "HTTP 502; Accept: application/sparql-results+json",
      "endTime": "2026-11-28T12:41:34.597018940+00:00",
      "error": {
        "@id": "#error"
      }
    }
  ]
}

Download ro-crate-metadata.json

ro-crate-metadata.json

PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?subclass ?subclassName ?superclass ?superclassName ?start ?end WHERE {
  ?subclass p:P279 ?subclassStatement .
  ?subclassStatement ps:P279 ?superclass ;
                     pq:P580 ?start ;
                     pq:P582 ?end .

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q22938576 .   # not a race (competition)
  }

  FILTER NOT EXISTS {
    ?subclass wdt:P31/wdt:P279* wd:Q3139516 .  # not an abbot or other church official
  }

  ?subclass rdfs:label ?subclassName .
  ?superclass rdfs:label ?superclassName .
  FILTER(LANG(?subclassName) = "en")
  FILTER(LANG(?superclassName) = "en")
}
ORDER BY ?subclassName ?start ?end

Download query.rq

query.rq