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/.

Bot Passwords
To use the API you will need Mediawiki-API credentials. For this, you must enable Bot Passwords by adding to you LocalSettings.php. Afterwards go to the Special:BotPasswords page of your wiki, create a new bot password and write down the username and password.

Settings
An example config is included. You need to insert your own wikiurl and bot credentials. Change values as desired. Afterwards you can start the api.

Start the API
Use with you config file to start the API. You can then find more docs at http://localhost:5000/.

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