Lua Extension for MediaWiki to access the REST APIs

Maintainers

Package info

github.com/StarCitizenTools/mediawiki-extensions-Apiunto

Type:mediawiki-extension

pkg:composer/starcitizentools/apiunto

Statistics

Installs: 258

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-28 21:28 UTC

This package is auto-updated.

Last update: 2026-05-28 21:28:10 UTC


README

Apiunto lets MediaWiki templates pull live data from REST APIs. Configure an API source once in LocalSettings.php, then fetch from it in Lua with mw.ext.Apiunto.fetch(). Responses are cached automatically, so repeated lookups don't re-hit the upstream API.

CI

Requirements

  • MediaWiki 1.43 or later
  • PHP 8.1 or later
  • Scribunto (hard dependency)

Installation

Clone or download this repository into your extensions/ directory, then load it in LocalSettings.php:

wfLoadExtension( 'Apiunto' );

$wgApiuntoSources = [
    'StarCitizenWikiAPI' => [
        'baseUrl' => 'https://api.star-citizen.wiki/api/',
        'token' => '', // optional
        'timeout' => 5, // optional, default 5
        'cacheDuration' => 3600, // optional, default 86400
    ],
];

Usage

Lua

local api = mw.ext.Apiunto

-- Request data for the Greycat Industrial ROC
-- Docs: https://docs.star-citizen.wiki/v2
-- Output: https://api.star-citizen.wiki/api/v2/vehicles/ROC
local roc = api.fetch( 'StarCitizenWikiAPI', 'v2/vehicles/ROC' )

fetch( source, uri, args ) takes:

  • source — a source name from $wgApiuntoSources
  • uri — the endpoint path to request
  • args (optional) — a table of query parameters to append. Array values are joined with commas; empty values are dropped.
-- Resolves to v2/vehicles?manufacturer=AEGS&limit=10
local ships = api.fetch( 'StarCitizenWikiAPI', 'v2/vehicles', {
    manufacturer = 'AEGS',
    limit = 10,
} )

Configurations

Variable Default Description
$wgApiuntoSources [] An array of API sources. Each source accepts baseUrl, and optional token, timeout (seconds, default 5), and cacheDuration (seconds, default 86400).
$wgApiuntoEnableCache true Whether to cache API responses.

Caching

Each response is cached for its source's cacheDuration. Purging a page (action=purge) clears the Apiunto responses cached for it, and a page's information page (action=info) shows the current cache status, URL, and time remaining.

To purge the entire cache from the command line:

php maintenance/run.php extensions/Apiunto/maintenance/purgeCache.php

Add --dry-run to preview what would be purged without deleting anything.