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 all api.php URLs: $wgScriptPath is '' on this wiki, so api.php is at the document root, not /w/ (via update-page on MediaWiki MCP Server)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{TOC right}}
__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 5: Line 6:


No authentication is required. All data is publicly readable.
No authentication is required. All data is publicly readable.
== URL layout ==
This wiki uses two URL paths:
* '''Articles''' live at <code>/wiki/PageName</code> (e.g. <code>https://wiki.everycrt.com/wiki/Sony_KV-20FV300</code>).
* '''Scripts''' live at the document root: <code>/api.php</code>, <code>/rest.php</code>, <code>/index.php</code>, <code>/load.php</code>. The Action API is at <code>https://wiki.everycrt.com/api.php</code> — not <code>/w/api.php</code> as on Wikipedia.


== Sync pattern ==
== Sync pattern ==
Line 18: Line 26:


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).
'''Human-readable view:''' [[EveryCRT:Data API/manifest]]


'''Programmatic fetch (recommended):'''
'''Programmatic fetch (recommended):'''


<pre>GET https://wiki.everycrt.com/w/api.php?action=expandtemplates&text=%7B%7B%23invoke%3ADataAPIManifest%7Cjson%7D%7D&prop=wikitext&format=json&formatversion=2</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=expandtemplates&text=%7B%7B%23invoke%3ADataAPIManifest%7Cjson%7D%7D&prop=wikitext&format=json&formatversion=2</pre>


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:


<syntaxhighlight lang="javascript">
<pre>
const url = 'https://wiki.everycrt.com/w/api.php'
const url = 'https://wiki.everycrt.com/api.php'
   + '?action=expandtemplates'
   + '?action=expandtemplates'
   + '&text=%7B%7B%23invoke%3ADataAPIManifest%7Cjson%7D%7D'
   + '&text=%7B%7B%23invoke%3ADataAPIManifest%7Cjson%7D%7D'
Line 40: Line 46:


console.log(manifest.entity_types);
console.log(manifest.entity_types);
</syntaxhighlight>
</pre>
 
The current manifest is rendered at the [[#Live manifest|bottom of this page]] for human reading.


== Listing entities ==
== Listing entities ==
Line 46: Line 54:
Use Semantic MediaWiki's <code>action=ask</code> endpoint to enumerate pages of a given entity type. The manifest's <code>list_url</code> for each entity type does exactly this — returning every page with its <code>Modification date</code>, which is what you want for indexing and for driving incremental sync:
Use Semantic MediaWiki's <code>action=ask</code> endpoint to enumerate pages of a given entity type. The manifest's <code>list_url</code> for each entity type does exactly this — returning every page with its <code>Modification date</code>, which is what you want for indexing and for driving incremental sync:


<pre>GET https://wiki.everycrt.com/w/api.php?action=ask&format=json&formatversion=2&query=[[Category:CRT models]]|?Modification date|limit=500</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=ask&format=json&formatversion=2&query=[[Category:CRT models]]|?Modification date|limit=500</pre>


The query supports any SMW ask syntax — additional printouts, filters, ordering, etc.
The query supports any SMW ask syntax — additional printouts, filters, ordering, etc.
Line 55: Line 63:
'''Example — all Sony CRT models with screen size and release year:'''
'''Example — all Sony CRT models with screen size and release year:'''


<pre>GET https://wiki.everycrt.com/w/api.php?action=ask&format=json&query=[[Category:CRT models]][[Has brand::Sony]]|?Has screen size inches|?Has release year|limit=500</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=ask&format=json&query=[[Category:CRT models]][[Has brand::Sony]]|?Has screen size inches|?Has release year|limit=500</pre>


For interactive query development, use [[Special:Ask]].
For interactive query development, use [[Special:Ask]].
Line 63: Line 71:
For a single page, the <code>action=browsebysubject</code> endpoint returns ''every'' SMW fact known about it — including subobjects (CRT inputs, outputs, voltage ranges, etc.):
For a single page, the <code>action=browsebysubject</code> endpoint returns ''every'' SMW fact known about it — including subobjects (CRT inputs, outputs, voltage ranges, etc.):


<pre>GET https://wiki.everycrt.com/w/api.php?action=browsebysubject&format=json&formatversion=2&subject=Sony_KV-20FV300</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=browsebysubject&format=json&formatversion=2&subject=Sony_KV-20FV300</pre>


This is the right endpoint for "give me everything you know about this entity" — no need to enumerate properties up front. New properties added to the wiki are automatically included in the response.
This is the right endpoint for "give me everything you know about this entity" — no need to enumerate properties up front. New properties added to the wiki are automatically included in the response.
Line 75: Line 83:
For incremental sync, poll <code>action=query&list=recentchanges</code> filtered by a timestamp. The standard MediaWiki [[Special:RecentChanges]] view is the human-readable equivalent:
For incremental sync, poll <code>action=query&list=recentchanges</code> filtered by a timestamp. The standard MediaWiki [[Special:RecentChanges]] view is the human-readable equivalent:


<pre>GET https://wiki.everycrt.com/w/api.php?action=query&list=recentchanges&format=json&formatversion=2&rcprop=title|timestamp|ids|sizes|user&rclimit=500&rcend=2026-05-01T00:00:00Z</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=query&list=recentchanges&format=json&formatversion=2&rcprop=title|timestamp|ids|sizes|user&rclimit=500&rcend=2026-05-01T00:00:00Z</pre>


A typical sync loop:
A typical sync loop:


# 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=<previous timestamp></code>.
# On the next sync, fetch recent-changes with <code>rcend=&lt;previous timestamp&gt;</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 86: Line 94:
To filter to specific namespaces, add <code>&rcnamespace=0|3000</code> (main + Document, for example). Namespace IDs are listed via:
To filter to specific namespaces, add <code>&rcnamespace=0|3000</code> (main + Document, for example). Namespace IDs are listed via:


<pre>GET https://wiki.everycrt.com/w/api.php?action=query&meta=siteinfo&siprop=namespaces&format=json&formatversion=2</pre>
<pre>GET https://wiki.everycrt.com/api.php?action=query&meta=siteinfo&siprop=namespaces&format=json&formatversion=2</pre>


== RDF export ==
== RDF export ==
Line 115: Line 123:


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 135:
* [[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
* [[EveryCRT:Data API/manifest]] — human-readable view of the manifest
* [[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]]
MediaWiki Appliance - Powered by TurnKey Linux