Developers
NeoWiki exposes a programmable surface: a graph database, parser functions, a Lua library, special pages, and a REST API. This page demonstrates each, showing the wikitext source alongside the rendered result.
Browse
- Special:Schemas: all schemas
- Special:Layouts: all layouts
- Special:NeoJson/<subject id>: view any subject as JSON
Query the graph
The {{#cypher_raw}} parser function runs a Cypher query and returns the raw JSON.
Source:
{{#cypher_raw:MATCH (m:Museum) RETURN m.name AS name, m.`Annual visitors` AS visitors ORDER BY visitors DESC LIMIT 5}}
Result:
[
{
"name": "Mus\u00e9e d'Orsay",
"visitors": 3270000
},
{
"name": "Museo del Prado",
"visitors": 3200000
},
{
"name": "Rijksmuseum",
"visitors": 2700000
},
{
"name": "Kunsthistorisches Museum",
"visitors": 1800000
}
]
Read values in wikitext
The {{#neowiki_value}} parser function reads a single property from a subject on a page.
Source:
{{#neowiki_value:Annual visitors|page=Rijksmuseum}}
Result: 2700000
Source:
{{#neowiki_value:Founded at|page=ACME Inc}}
Result: 2005
Read values in Lua
The mw.neowiki Lua library exposes structured data to your Scribunto modules. The example below reads a single property and runs a Cypher query.
local p = {}
local nw = require( 'mw.neowiki' )
function p.foundedYear( frame )
local year = nw.getValue( 'Founded', { page = frame.args[1] } )
return tostring( year or '' )
end
function p.oldestMuseums( frame )
local rows = nw.query(
'MATCH (m:Museum) RETURN m.name AS name, m.Founded AS year ORDER BY year LIMIT 3'
)
local list = {}
for _, row in ipairs( rows ) do
list[#list + 1] = '* ' .. row.name .. ' (' .. row.year .. ')'
end
return table.concat( list, '\n' )
end
return p
Invoke it from wikitext:
{{#invoke:LuaExample|foundedYear|Rijksmuseum}}
{{#invoke:LuaExample|oldestMuseums}}
Result:
Rijksmuseum was founded in 1800.
Oldest museums in this demo:
- Rijksmuseum (1800)
- Museo del Prado (1819)
- Kunsthistorisches Museum (1891)
For the full library reference, see the Lua API documentation.
Reactive UI
NeoWiki components embed in pages as reactive UIs that update without a page reload. See Subject views for the same Sandbox subject in three layouts, with edits propagating between them.
REST API
NeoWiki exposes a REST API for reading and writing structured data. The OpenAPI 3.0 spec is auto-generated:
- OpenAPI spec:
/rest.php/specs/v0/module/- - Module discovery:
/rest.php/specs/v0/discovery
Representative read endpoints:
GET /neowiki/v0/subject/{subjectId}GET /neowiki/v0/schema/{schemaName}
For full endpoint documentation, see the OpenAPI spec above.