# Querying the Digital Narrative Knowledge Base (DNKB)

DNKB is a research archive of digital narrative and electronic literature, with structured records in its own Wikibase. This is the public data reference for people and agents, not repository development instructions.

- Human guide: https://dnkb.cdn.uib.no/docs/querying
- SPARQL editor: https://query.wbs.cdn.uib.no/
- SPARQL endpoint: https://query.wbs.cdn.uib.no/sparql
- Wikibase API: https://wbs.cdn.uib.no/w/api.php
- JSON reference: https://dnkb.cdn.uib.no/docs/querying.json
- Examples last verified: 2026-11-02. Example results are live, not fixed counts.

## Prefixes

```sparql
PREFIX wd: <https://wbs.cdn.uib.no/entity/>
PREFIX wdt: <https://wbs.cdn.uib.no/prop/direct/>
PREFIX p: <https://wbs.cdn.uib.no/prop/>
PREFIX ps: <https://wbs.cdn.uib.no/prop/statement/>
PREFIX pq: <https://wbs.cdn.uib.no/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
```

## Query and interpretation rules

- Query the live endpoint for current answers. Send GET ?query=... (URL-encoded) or POST form data with a query field, Accept: application/sparql-results+json, and a descriptive User-Agent such as DNKB-research/1.0. The service can reject the default Node.js User-Agent with HTTP 403. Read-only queries do not require login.
- Always declare the local prefixes explicitly. These are HTTPS entity IRIs; neither the wbs-blue hostname nor Wikidata IRIs identify the same local entities. Local Q/P IDs are not Wikidata IDs.
- Resolve unfamiliar IDs through the Wikibase API: action=wbsearchentities, search=<label>, language=en, format=json, type=item (or type=property). Inspect candidates and their statements; never assume the first search match is correct.
- Inspect entities with action=wbgetentities&ids=Q91&props=labels|descriptions|claims&languages=en&format=json, or /wiki/Special:EntityData/Q91.json on the Wikibase host. JSON-LD is available at the same path with .jsonld.
- Use ?item wdt:P1/wdt:P108* wd:Q7007 for creative works and wd:Q91 for humans, including subclasses. Critical writing (Q7008) is a separate branch, not a creative work.
- State the interpretation: language, country of origin and citizenship are different. Citation rankings here count distinct citing critical writings via P120; journal rankings count distinct critical writings via P7. These measure DNKB coverage, not worldwide totals; ties are ordered by item IRI.
- Missing statements are not negative facts. Zero results mean no recorded matches, not that the works or people do not exist. Some authors exist only as P113 name strings and cannot be counted as linked P6 person items.
- COUNT(DISTINCT ?item) avoids overcounting joins. Label language filters belong inside OPTIONAL so missing English labels do not exclude items. Keep undated works visible when grouping by year.
- wdt: queries use truthy statements, generally preferred rank if present, otherwise normal rank; deprecated statements are excluded. Use p:/ps:/pq: for statement ranks, qualifiers and more detailed provenance.
- Results reflect the recorded data and may lag recent wiki edits. Software associations do not prove that a recorded publication date is the release date of that software version.
- Start exploratory listings with LIMIT 100. Avoid unbounded graph scans and repeated parallel queries; use a timeout and report endpoint errors instead of interpreting them as empty results.
- Show the executed query, query-service link, retrieval date, interpretation and coverage limits alongside answers. If your tools cannot execute SPARQL, provide a runnable editor link and say the results are unverified. Do not fabricate counts.

## Common local properties

- P1: instance of. Class of an item; use P108 paths to include subclasses.
- P108: subclass of. Class hierarchy, from child to parent.
- P6: author. Links a work to a person item.
- P113: author name string. A literal name, not a person item; person-based counts can omit these authors.
- P10: language of work or name. Language, not country of origin or citizenship.
- P11: country of origin. Country recorded for a work.
- P29: publication date. Use YEAR() for grouping; dates can describe original publication rather than a software version.
- P120: cites work. Links a citing critical writing to the cited work.
- P7: published in. Links a writing to its journal or other containing publication.
- P86: software engine. The property used to link works to Adobe Flash and Twine.
- P100: programmed in. Do not assume this is the property used for authoring software; inspect actual statements.
- P3: Wikidata entity identifier. External Wikidata identifier; local Q/P IDs have different meanings.

## Common local items

- Q91: Human
- Q7007: Creative work
- Q7008: Critical writing
- Q10819: DNKB work
- Q6783: Academic journal
- Q97: Adobe Flash
- Q132: Twine

## Examples

### Which 5 creative works are the most cited?

Counts distinct critical writings in DNKB that cite each creative work, not citations across the wider literature.

```sparql
PREFIX wd: <https://wbs.cdn.uib.no/entity/>
PREFIX wdt: <https://wbs.cdn.uib.no/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?work ?title ?citations WHERE {
  {
    SELECT ?work (COUNT(DISTINCT ?writing) AS ?citations) WHERE {
      ?work wdt:P1/wdt:P108* wd:Q7007 .
      ?writing wdt:P1/wdt:P108* wd:Q7008 ;
               wdt:P120 ?work .
    }
    GROUP BY ?work
    ORDER BY DESC(?citations) ?work
    LIMIT 5
  }
  OPTIONAL { ?work rdfs:label ?title . FILTER(LANG(?title) = "en") }
}
ORDER BY DESC(?citations) ?work
```

[Open in query service](https://query.wbs.cdn.uib.no/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fwbs.cdn.uib.no%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fwbs.cdn.uib.no%2Fprop%2Fdirect%2F%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0ASELECT%20%3Fwork%20%3Ftitle%20%3Fcitations%20WHERE%20%7B%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fwork%20(COUNT(DISTINCT%20%3Fwriting)%20AS%20%3Fcitations)%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fwork%20wdt%3AP1%2Fwdt%3AP108*%20wd%3AQ7007%20.%0A%20%20%20%20%20%20%3Fwriting%20wdt%3AP1%2Fwdt%3AP108*%20wd%3AQ7008%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP120%20%3Fwork%20.%0A%20%20%20%20%7D%0A%20%20%20%20GROUP%20BY%20%3Fwork%0A%20%20%20%20ORDER%20BY%20DESC(%3Fcitations)%20%3Fwork%0A%20%20%20%20LIMIT%205%0A%20%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fwork%20rdfs%3Alabel%20%3Ftitle%20.%20FILTER(LANG(%3Ftitle)%20%3D%20%22en%22)%20%7D%0A%7D%0AORDER%20BY%20DESC(%3Fcitations)%20%3Fwork)

### Top 10 journals by critical writing publications

Counts distinct critical writings linked to each academic journal through “published in”. Unlinked publications are excluded.

```sparql
PREFIX wd: <https://wbs.cdn.uib.no/entity/>
PREFIX wdt: <https://wbs.cdn.uib.no/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?journal ?title ?publications WHERE {
  {
    SELECT ?journal (COUNT(DISTINCT ?writing) AS ?publications) WHERE {
      ?journal wdt:P1/wdt:P108* wd:Q6783 .
      ?writing wdt:P1/wdt:P108* wd:Q7008 ;
               wdt:P7 ?journal .
    }
    GROUP BY ?journal
    ORDER BY DESC(?publications) ?journal
    LIMIT 10
  }
  OPTIONAL { ?journal rdfs:label ?title . FILTER(LANG(?title) = "en") }
}
ORDER BY DESC(?publications) ?journal
```

[Open in query service](https://query.wbs.cdn.uib.no/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fwbs.cdn.uib.no%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fwbs.cdn.uib.no%2Fprop%2Fdirect%2F%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0ASELECT%20%3Fjournal%20%3Ftitle%20%3Fpublications%20WHERE%20%7B%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fjournal%20(COUNT(DISTINCT%20%3Fwriting)%20AS%20%3Fpublications)%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fjournal%20wdt%3AP1%2Fwdt%3AP108*%20wd%3AQ6783%20.%0A%20%20%20%20%20%20%3Fwriting%20wdt%3AP1%2Fwdt%3AP108*%20wd%3AQ7008%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP7%20%3Fjournal%20.%0A%20%20%20%20%7D%0A%20%20%20%20GROUP%20BY%20%3Fjournal%0A%20%20%20%20ORDER%20BY%20DESC(%3Fpublications)%20%3Fjournal%0A%20%20%20%20LIMIT%2010%0A%20%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fjournal%20rdfs%3Alabel%20%3Ftitle%20.%20FILTER(LANG(%3Ftitle)%20%3D%20%22en%22)%20%7D%0A%7D%0AORDER%20BY%20DESC(%3Fpublications)%20%3Fjournal)
