Help:Extension:OttrParser/API

The Extension:OttrParser comes with an API to import and export .stotter files.

Comprehensive documentation can be found on the main page of the running instance, this will most likely be http://localhost:5000/.

Starting the API
When using the docker container, the API should already be running. For a manual install, it can be started from the git repository root with

Settings
To change settings, the API needs to be run with a custom config: an example config is included:

Export
The API provides 4 endpoints to export .stottr data from mediawiki: All endpoints can be accessed with a simple get request : and return a JSON object of the form containing valid .stottr syntax strings.

Import
To import all data from a .stottr file into the wiki the endpoint is used. A minimal example in python looks like this: data contains a full .stottr file as string.

template_namespace and instance_namespace can be set to put imported templates or instances in a namespace.

overwrite can be set to overwrite existing pages. If set to False existing pages will not be updated.

The API will do the following things when importing:

 * Create a new wikipage for each template in the .stotter file
 * Create a new wikipage for each instance in the .stotter file
 * Add prefixes present in the .stottr file to the Ottr:OttrPrefixes page
 * create list entries in the Special:OttrApiEdits page