EveryCRT:Data API: Difference between revisions
Initial Data API documentation: manifest, list, facts, recent changes, RDF export, with example code and sync pattern (via create-page on MediaWiki MCP Server) |
Fix rendering: replace syntaxhighlight (extension not installed) with pre, drop missing TOC right template, inline the manifest viewer (REST API can't reach subpages) (via update-page on MediaWiki MCP Server) |
||
| Line 1: | Line 1: | ||
__NOCACHE__ | |||
__TOC__ | |||
The '''EveryCRT Data API''' is a documented way to fetch the structured data of [[Main Page|EveryCRT]] programmatically — for example, to build a third-party app that mirrors, indexes, or analyzes the wiki. | The '''EveryCRT Data API''' is a documented way to fetch the structured data of [[Main Page|EveryCRT]] programmatically — for example, to build a third-party app that mirrors, indexes, or analyzes the wiki. | ||
| Line 18: | Line 19: | ||
The manifest is a JSON document listing every canonical entity-type category, with live page counts and ready-to-use enumeration URLs. It updates automatically as the catalog grows; new entity types added in the future will appear here without API clients needing code changes (assuming they iterate over <code>entity_types</code> rather than hardcoding). | The manifest is a JSON document listing every canonical entity-type category, with live page counts and ready-to-use enumeration URLs. It updates automatically as the catalog grows; new entity types added in the future will appear here without API clients needing code changes (assuming they iterate over <code>entity_types</code> rather than hardcoding). | ||
'''Programmatic fetch (recommended):''' | '''Programmatic fetch (recommended):''' | ||
| Line 27: | Line 26: | ||
The response wraps the manifest in <code>expandtemplates.wikitext</code> as a string; parse that string as JSON: | The response wraps the manifest in <code>expandtemplates.wikitext</code> as a string; parse that string as JSON: | ||
< | <pre> | ||
const url = 'https://wiki.everycrt.com/w/api.php' | const url = 'https://wiki.everycrt.com/w/api.php' | ||
+ '?action=expandtemplates' | + '?action=expandtemplates' | ||
| Line 40: | Line 39: | ||
console.log(manifest.entity_types); | console.log(manifest.entity_types); | ||
</ | </pre> | ||
The current manifest is rendered at the [[#Live manifest|bottom of this page]] for human reading. | |||
== Listing entities == | == Listing entities == | ||
| Line 80: | Line 81: | ||
# Save your "last sync" timestamp (UTC ISO 8601) after each successful pass. | # Save your "last sync" timestamp (UTC ISO 8601) after each successful pass. | ||
# On the next sync, fetch recent-changes with <code>rcend= | # On the next sync, fetch recent-changes with <code>rcend=<previous timestamp></code>. | ||
# For each unique <code>title</code> in the response, re-fetch via <code>browsebysubject</code> (or remove from your index if it was a deletion — see <code>rctype=log</code> and <code>rcshow</code> options for handling deletes and moves). | # For each unique <code>title</code> in the response, re-fetch via <code>browsebysubject</code> (or remove from your index if it was a deletion — see <code>rctype=log</code> and <code>rcshow</code> options for handling deletes and moves). | ||
# Save the new "last sync" timestamp. | # Save the new "last sync" timestamp. | ||
| Line 115: | Line 116: | ||
If your app is doing something cool with EveryCRT data, drop a note on the community channels — we'd love to see it. | If your app is doing something cool with EveryCRT data, drop a note on the community channels — we'd love to see it. | ||
== Live manifest == | |||
This is the manifest as it would be returned by the [[#Manifest|programmatic fetch]] above, rendered live from [[Module:DataAPIManifest]]: | |||
{{#tag:pre|{{#invoke:DataAPIManifest|json}}}} | |||
== See also == | == See also == | ||
| Line 121: | Line 128: | ||
* [[Special:Ask]] — interactive SMW query builder | * [[Special:Ask]] — interactive SMW query builder | ||
* [[Special:Browse]] — interactive per-page fact browser | * [[Special:Browse]] — interactive per-page fact browser | ||
* [[Module:DataAPIManifest]] — Lua source of the manifest | * [[Module:DataAPIManifest]] — Lua source of the manifest | ||
* [[EveryCRT:Maintenance]] — wiki health and category audits | * [[EveryCRT:Maintenance]] — wiki health and category audits | ||
[[Category:EveryCRT administration]] | [[Category:EveryCRT administration]] | ||