Assist API

From Calidus HUB

What is it?

The API is a method of extracting data from Assist for your own use.

In general, any text will be in MediaWiki format.

The API is also useful for extracting stats.


How do I use it?

You can build and execute an API query graphically from the Special:ApiSandbox special page.

You can also directly type into the URL box on your browser.

Help is available through the standard MediaWiki pages.


Examples

The example we will look at are varieties of querying the Assist data for recent changes in a number of different ways.


Using the Sandbox

  • Go to the special page.
  • Select the "action", in this case "query".
  • Select the "format", in this case "xml".
    • If you choose format XML, you can style the results. If your mediawiki contains an XSL you can use it as follows:
      • Click "Format=xml" link on the left.
      • Enter the XSL. In this case, for Calidus Hub, for Recent Changes, use "MediaWiki:RC.xsl". This will format the results to HTML.
  • Click on the "action=query" link on the left.
  • Select "list" = what the query is to list - in this case "recentchanges".
  • Click on the "list=recentchanges" link on the left.
  • Check "rcstart" and enter the start date. Note that this is a history, so this start date is the time you wish to start LOOKING BACK from. e.g. today's date.
  • Optionally check "rcend" and enter the end date. Note that if the range is too wide, then this will not produce results. Instead rely on "rclimit" below.
  • Include or exclude users:
    • Enter "rcexcludeuser" for the user you wish to exclude.
    • Alternatively, enter "rcuser" for the user you wish to include
  • Check "rcprop" and enter the properties you want to report. This will default - you can remove and add and change the order of properties. In this case: user, title, timestamp.
  • Enter rclimit. "MAX" or "5000"
  • Scroll to the top and click Make Request.

The browser will show you a preview the results. For plain json or XML, you can copy the results. Or you can copy the link and paste into your browser for formatted results (especially if you have used an XSL).


Using a Browser

Simply type in your Assist core URL, followed by api.php, followed by your querystring.

Description:

  • Core wiki URL e.g. "https://calidusassist.adcservices.apteancloud.com/calidus-assist/OBS/"
  • Add api.php
  • Start the querystring - "?". Each additional parameter after the first requires an ampersand "&".
  • "action" - the action you wish to perform, in this case a "query".
  • "format" - the format of the response. Choose "json" or "xml".
    • If you choose format XML, you can style the results. If your mediawiki contains an XSL you can use it as follows:
      • "xslt". For Calidus Hub, for Recent Changes, use "MediaWiki:RC.xsl". This will format the results to HTML.
  • "list" - what you want the query to list, in this case "recentchanges"
  • "rcstart" - enter the start date. Note that this is a history, so this start date is the time you wish to start LOOKING BACK from. e.g. today's date.
  • "rcend" - Optional, enter the end date. Note that if the range is too wide, then this will not produce results. Instead rely on "rclimit" below.
  • "rcexcludeuser" - for the user you wish to exclude.
  • "rcprop" - enter the properties you want to report. In this case: "user, title, timestamp".
  • "rclimit" - "MAX" or "5000"


As values:

  • https://calidusassist.adcservices.apteancloud.com/calidus-assist/OBS/
  • api.php
  • ?
  • action=query
  • &format=xml
    • If you choose format XML, you can style the results. If your mediawiki contains an XSL you can use it as follows:
    • Optional: &xslt=MediaWiki%3ARC.xsl
  • &list=recentchanges
  • &rcstart=2025-10-01T09%3A54%3A58.000Z
    • Optional: &rcend=2025-01-01T09%3A54%3A58.000Z
  • &rcexcludeuser=anw
  • &rcprop=user%7Ctitle%7Ctimestamp
  • &rclimit=max


Sample link:


Creating an XSL

If you export in XML format, you have the option of specifying an XSL (stylesheet). Simply put, this can format the page as a proper web page, which is much easier to read and print.

To do this:

  • Create a page called /MediaWiki:(whateveryouwant).xsl - add this to the base URL of youre Assist e.g. https://calidusassist.adcservices.apteancloud.com/calidus-assist/OBS/index.php?title=MediaWiki:MyXSL.xsl
  • Create the XSL and save.
  • Add this to your export options (as shown above)

Sample XSL

The following works for recent changes exports. It will work regardless of how many or which columns you select to report, and format the result as a simple table. Simple styling has been added.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="api/query/recentchanges">
    <html>
      <head>
        <style>
        body {
            font-family: 'Segoe UI', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Lato', 'Liberation Sans', 'Noto Sans', 'Helvetica Neue', 'Helvetica', sans-serif;
            margin: 0;
            padding: 0;
        }
        table {
            border-collapse: collapse;
        }
        table thead tr {
            background-color: grey;
            color: white;
        }
        table tbody tr {
            vertical-align: top;
        }
        </style>
      </head>
      <body>
        <h2>Recent Changes</h2>
        <table border="1">
          <thead>
            <tr>
              <xsl:for-each select="rc[1]/@*">
                <th><xsl:value-of select="name()"/></th>
              </xsl:for-each>
            </tr>
          </thead>
          <tbody>
            <xsl:for-each select="rc">
              <tr>
                <xsl:for-each select="@*">
                  <td><xsl:value-of select="."/></td>
                </xsl:for-each>
              </tr>
            </xsl:for-each>
          </tbody>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>