Wikidata
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/wikidataDEPENDENCIES
@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 updateModel 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.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| cacheDir? | string | Shared web-cache directory to read cached responses from (must match |
| apiUrl? | string | Wikidata action API base URL |
| language? | string | Language for labels, descriptions and search |
| site? | string | Site id used for sitelink lookups (e.g. enwiki, commonswiki) |
| Argument | Type | Description |
|---|---|---|
| query | string | Search query (an entity label) |
| limit? | number | Maximum number of results |
| Argument | Type | Description |
|---|---|---|
| id | string | Wikidata QID, e.g. 'Q286116' |
| Argument | Type | Description |
|---|---|---|
| title | string | Page title to resolve |
| site? | string | Override the global site id |
| Argument | Type | Description |
|---|---|---|
| query | string | Search query (an entity label) |
| limit? | number | Maximum number of results |
| language? | string | Override the global language |
| Argument | Type | Description |
|---|---|---|
| id | string | Wikidata QID, e.g. 'Q286116' |
| Argument | Type | Description |
|---|---|---|
| title | string | Page title to resolve (e.g. 'Alfred Bester') |
| site? | string | Override the global site id |
| Argument | Type | Description |
|---|---|---|
| id | string | Wikidata QID whose claims to extract |
| property | string | Property ID, e.g. 'P31' (instance of) |
| Argument | Type | Description |
|---|---|---|
| id | string | Wikidata QID whose instance-of (P31) to extract |
| key? | string | Optional data name for the result (defaults to the QID). |
Resources
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)
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)
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)
Modified 1 behaviors. Added 3 workflows. updated dependencies
- 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