Skip to main content

Wikidata

@svendowideit/wikidatav2026.10.23.1· 1d agoBEHAVIORSWORKFLOWS
01README

A Wikidata domain parser that reads cached responses from the shared cache owned by @svendowideit/web-cache. It fetches nothing itself — fetch, cache, pacing and rate-limit retry are web-cache's job.

WHAT IT DOES

Parses cached Wikidata responses into structured swamp data: search entities, fetch an entity's claims/labels/descriptions, resolve a Wikipedia title to a QID via its sitelink, and extract claims such as instance-of into simple key/value form.

INSTALL

swamp extension pull @svendowideit/web-cache
swamp extension pull @svendowideit/wikidata

DEPENDENCIES

@svendowideit/web-cache (hard dependency, declared in this manifest). No host packages are installed.

RUN

# Fetch + cache a Wikidata entity.
swamp model @svendowideit/web-cache method run get cache \
  --input url="https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q286116&format=json"

# Parse the cached entity.
swamp model @svendowideit/wikidata method run get-entity wd \
  --input id="Q286116"

# Extract instance-of values from the cached entity.
swamp model @svendowideit/wikidata method run get-instance-of wd \
  --input id="Q286116"

CONFIGURE

All optional global arguments: cacheDir (default ~/.swamp/web-cache), apiUrl (default www.wikidata.org), language (default en), site (default enwiki). See the README for the full argument tables.

UPGRADE

This extension installs nothing on the host, so an upgrade is:

  swamp extension update

Model definitions record the version they were created with; the model's bundled upgrades entry migrates them on the next method run. Swamp data is preserved.

WHAT IT INSTALLS

Nothing on the host — no services, triggers, or webhooks. Only pulled extension files and swamp data resources.

02Behaviors1
@svendowideit/wikidatav2026.10.23.1wikidata.ts

Global Arguments

ArgumentTypeDescription
cacheDir?stringShared web-cache directory to read cached responses from (must match
apiUrl?stringWikidata action API base URL
language?stringLanguage for labels, descriptions and search
site?stringSite id used for sitelink lookups (e.g. enwiki, commonswiki)
fn search-url(query: string, limit?: number)
Build the wbsearchentities URL (no fetching). Use this to feed a
ArgumentTypeDescription
querystringSearch query (an entity label)
limit?numberMaximum number of results
fn entity-url(id: string)
Build the wbgetentities URL for a QID (no fetching). Use this to feed
ArgumentTypeDescription
idstringWikidata QID, e.g. 'Q286116'
fn resolve-title-url(title: string, site?: string)
Build the sitelink-lookup URL (title → QID) (no fetching). Use this
ArgumentTypeDescription
titlestringPage title to resolve
site?stringOverride the global site id
fn search(query: string, limit?: number, language?: string)
Parse a cached wbsearchentities response into matching entities
ArgumentTypeDescription
querystringSearch query (an entity label)
limit?numberMaximum number of results
language?stringOverride the global language
fn get-entity(id: string)
Parse a cached wbgetentities response for a QID into its entity
ArgumentTypeDescription
idstringWikidata QID, e.g. 'Q286116'
fn resolve-title(title: string, site?: string)
Resolve a page title to a Wikidata QID via its sitelink. Returns the
ArgumentTypeDescription
titlestringPage title to resolve (e.g. 'Alfred Bester')
site?stringOverride the global site id
fn get-claims(id: string, property: string)
Extract the value QIDs for a single property (e.g. P31) from a cached
ArgumentTypeDescription
idstringWikidata QID whose claims to extract
propertystringProperty ID, e.g. 'P31' (instance of)
fn get-instance-of(id: string, key?: string)
Convenience: extract the instance-of (P31) value QIDs from a cached
ArgumentTypeDescription
idstringWikidata QID whose instance-of (P31) to extract
key?stringOptional data name for the result (defaults to the QID).

Resources

search(infinite)— Parsed wbsearchentities results
entity(infinite)— A parsed Wikidata entity (claims, labels, descriptions)
resolution(infinite)— Resolved Wikipedia title → Wikidata QID via its sitelink
claims(infinite)— Extracted property claim values for an entity
instance-of(infinite)— Instance-of (P31) value QIDs for an entity
url(infinite)— A built Wikidata URL (for the fetch seam)
03Workflows3
@svendowideit/wikidata-get-entity1698ba0f-fdc6-4f9b-9fec-976b14a16aa1

Fetch + parse a Wikidata entity (wbgetentities) through the shared cache, transparently. The caller does not care whether a fetch happened or a cache hit was used (`cached` is metadata only). Steps: build the entity URL → web-cache-fetch → parse the cached body. Inputs: id — Wikidata QID (e.g. Q286116) cacheDir — shared cache dir (default ~/.swamp/web-cache)

mainFetch + parse a Wikidata entity.
1.build-url— Build the wbgetentities URL.
2.fetch— Fetch + cache the entity URL.
3.parse— Parse the cached entity body.
@svendowideit/wikidata-instance-of3b614493-4c53-4089-bd49-c648a927ea57

Extract an entity's instance-of (P31) value QIDs through the shared cache, transparently. The caller does not care whether a fetch happened or a cache hit was used. Steps: build the entity URL → web-cache-fetch → parse + extract P31. Inputs: id — Wikidata QID (e.g. Q286116) key — optional data name for the result (defaults to QID) cacheDir — shared cache dir (default ~/.swamp/web-cache)

mainExtract instance-of (P31) for an entity.
1.build-url— Build the wbgetentities URL.
2.fetch— Fetch + cache the entity URL.
3.parse— Extract P31 values from the cached entity.
@svendowideit/wikidata-resolve-title229a2890-8582-4ec3-90b7-95ae427acad9

Resolve a Wikipedia page title to a Wikidata QID via its sitelink, through the shared cache, transparently. Steps: build the sitelink URL → web-cache-fetch → parse the cached body. Inputs: title — Wikipedia page title site — sitelink site id (default enwiki) cacheDir — shared cache dir (default ~/.swamp/web-cache)

mainResolve a title to a QID.
1.build-url— Build the sitelink lookup URL.
2.fetch— Fetch + cache the sitelink URL.
3.parse— Parse the cached sitelink body into a QID.
04Previous Versions2
2026.09.20.3

Modified 1 behaviors. Added 3 workflows. updated dependencies

2026.09.20.2
05Stats
A
93 / 100
Downloads
29
Archive size
13.5 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License1/2partial

    no SPDX license declared

  • Verified public repository2/2earned
06Platforms