Arelle’ web service API, based on REST, provides XBRL services to non-Python applications, such as Excel, Java, and C#.

The web services can operate as a stand-alone single-process web server, or can operate under another web server.  When operating stand-alone and in a single-process, Arelle can interact with multiple interfaces and requests without reloading its object model, such as QuickBooks XBRL-GL interfaces or separate API requests to perform subsequent operations on the same object model.  When operating under an independent web server (such as IIS or Apache) the examples below have each REST API request handled as an independent request in an independent process, using CGI, which is suitable for a production environment.  In each of these Arelle operates from its compiled binary application, without requiring installing of Python and python library packages within the web server.

To start as a simple stand-alone web server (where the Arelle executable handles the web service requests itself, e.g., without using IIS or Apache):

  • Windows:  Start menu->programs->Arelle->Start Web Server, scripts\startWebServer.bat, or ArelleCmdLine.exe –webserver locahost:8080
  • Mac/OS: double-click startWebServer.command

The default port is “localhost:8080”.  The windows port can be changed by editing properties of the “Start Web Server” menu shortcut, .bat/.command file, or command line parameter.  The web server is terminated by cntrl-C to the webserver’s window.

The simple stand-alone web server REST API starts with “/”, so REST APIs start with the path http://localhost:8080/rest/xbrl/..., or help is at http://localhost:8080/help

The next two options provide Arelle’s REST API using web servers like IIS or Apache, invoking Arelle from the compiled binary application distribution for each.
To start as a CGI process under IIS, where each request will run as an independent process:

  • Install the Windows executable.  arelleCmdLine.exe will detect when it is running as a CGI.
  • Install IIS features for CGI (if not yet present in IIS).
  • Add a web site for the CGI, with its own port number (such as 8080), an application pool, advanced settings physical path to C:\Program Files\Arelle (or your installation location).  Set permissions on that directory (such as Everyone or IIS processes, so they can write the web.config directory and any other files as needed).
  • Set application pool framework version at 2.0, and maximum worker processes at number of CPU cores available (under advanced properties).
  • Add handler mapping for Arelle, similar to this, using * so REST paths to go into Arelle:
    • Request path: *
    • Executable: “C:\Program Files\Arelle\arelleCmdLine.exe” %s
    • Name: Arelle
      • Arelle’s cache directory for IIS defaults to

    C:\Windows\Temp\Arelle

      • , and is created on initial startup for you. This can be confirmed by REST API

    /rest/configure?environment

      . If you copy into this directory be sure to set permissions, such as IUSR.

This IIS web server configuration REST API starts with “/”, so REST APIs start with the path http://localhost:8080/rest/xbrl/...

Here are contributed steps by another user to set up Arelle under IIS:

1.For security reasons every CGI has to be registered in the ISAPI/CGI Restriction list: Right click on Web server name and double click on ISAPI and CGI Restrictions. Add C:\ArelleCGI\arelleCmdLine.exe with desc: arelleCmdLine and check “Allow extension path to execute”

2.Create web site with port number pointing to c:\ArelleInstallFolder(and or virtual directory under existing web site or newly created). If a web site is created it will by default assign AppPoolIDForOurApp as the security identity
under which the new web server will run.

We still don’t allow “Execute” access in this directory. For this you have to go to the Handler Mappings menu of the CGI virtual directory (make sure you select the CGI virtual directory on the left hand side!).

Go to the “Edit Feature Permissions” link in the Actions Menu on the right hand side, open it and check “Execute” and click “OK”.

3.Double click on CGI-exe in Handler Mappings (default name of the mapping that we enabled in step 2, but it needs to be configured) to edit this mapping
Request path = *.exe
Executable = C:\ArelleIISCGI\arelleCmdLine.exe %s –xdgConfigHome=”C:\ArelleIISCGI\cache”

4.We need to add IIS APPPOOL\AppPoolIDForOurApp account to the physical folder where Arelle was installe e.g. c:\ArelleInstallFolder (default permissions read are fine – since we are not writing to it.)

5.Modify IIS APPPOOL\AppPoolIDForOurApp permissions on c:\ArelleInstallFolder\cache folder (or whatever folder will be used to store Arelle config and cache) to include write permissions (read permissions are fine if we have cache already, but if we are able to get through the proxy or we have open access to the Internet write access is needed)

To start as a CGI installed under an Apache web server, where each request will run as a separate process:

  • Ensure that the web server has mod-cgi installed and a working cgi directory (such as /usr/lib/cgi-bin, as with Ubuntu).  Do not specify AcceptPathInfo (otherwise it will block the REST path following arelleCmdLine in the URL path).
  • Unzip the Linux executable within the mod-cgi directory (such as to a subdirectory arelle, so the path to arelleCmdLine is /usr/lib/cgi-bin/arelle/arelleCmdLine).  Ensure permissions will allow the web server to access the directory and execute.  The executable arelleCmdLine detects when it is running as a CGI instead of from a command script or shell.
  • Arelle needs a cache directory.  With Ubuntu this defaults to /var/www/.config/arelle.  Create those directories (probably needs sudo) and set their owners and groups (with Ubuntu user and group are set to www-data).

This Apache web server configuration REST API starts with /cgi-bin/arelle/arelleCmdLine, so REST APIs start with the path http://myhost.com/cgi-bin/arelle/arelleCmdLine/rest/xbrl/..., or help is at http://myhost.com/cgi-bin/arelle/arelleCmdLine/help

(There are other alternatives to running Arelle as a stand-alone single-process web server or running from compiled binary application distribution.  The single-process mode can use other servers supported by Python Bottle, some of which, like CherryPy, have multi-processing support.  The source code supports use as an WSGI application (automatically detected on start up of arelleCmdLine.py), which can be deployed in a web server which has managed Python support and source code integration expertise.  The Python 2.7 version of Arelle has been installed on Google App Engine (GAE), such as for api.arelle.org.)

Below is a table of the API from Arelle’s web service.  API implemented by the installed version of Arelle is obtained by starting Arelle’s web services and clicking (or entering this link to your browser – it assumes use of the default port, 8080): http://localhost:8080/help.

Web Service API

tr>

Arelle web API
/help This web page.
/about About web page, copyrights, etc.
Validation
/rest/xbrl/​{file}/​validation/​xbrl Validate document at {file}.
{file} may be local or web url, and may have “/” characters replaced by “;” characters (but that is not
necessary).
Example: /rest/​xbrl/​c:/a/b/c.xbrl/​validation/​xbrl?​media=xml: Validate entry instance
document at c:/a/b/c.xbrl (on local drive) and return structured xml results.
/rest/xbrl/​validation (Alternative syntax) Validate document, file is provided as a parameter (see below).
Example: /rest/​xbrl/​validation​?file=c:/a/b/c.xbrl&​media=xml: Validate entry instance
document at c:/a/b/c.xbrl (on local drive) and return structured xml results.
Parameters are optional after “?” character, and are separated by “&” characters,
as follows:
flavor standard: XBRL 2.1 and XDT validation. (default){sec*|edgar*}: SEC Edgar Filer Manual validation.
media html or xhtml: Html text results. (default)xml: XML structured results. json: JSON results.text: Plain text results (no markup).
file Alternate way to specify file name or url by a parameter.
import A list of files to import to the DTS, such as additional formula
or label linkbases. Multiple file names are separated by a ‘|’ character.
calc Specify calculation linkbase validation:

none or absent – no calculations validation
c10 or xbrl21 – Calc 1.0 (XBRL 2.1) calculations
c10d or xbrl21-dedup – Calc 1.0 (XBRL 2.1) calculations with de-duplication
c11r or round-to-nearest – Calc 1.1 round-to-nearest mode
c11t or truncation – Calc 1.1 truncation mode

efm-* Select Edgar Filer Manual (U.S. SEC) disclosure system validation. (Alternative to flavor parameter.):
efm-pragmatic: SEC-required rules, currently-allowed years
efm-strict: SEC-semantic additional rules, currently-allowed years
efm-pragmatic-all-years: SEC-required rules, all years
efm-strict-all-years: SEC-semantic additional rules, all years
ifrs Specify IFRS Global Filer Manual validation.
hmrc Specify HMRC validation.
sbr-nl Specify SBR-NL taxonomy validation.
utr Select validation with respect to Unit Type Registry.
formulaAsserResultCounts Report formula assertion counts.
formulaVarSetExprResult Trace variable set formula value, assertion test results.
formulaVarFilterWinnowing Trace variable set filter winnowing.
{other} Other detailed formula trace parameters:formulaParamExprResult, formulaParamInputValue, formulaCallExprSource, formulaCallExprCode, formulaCallExprEval,
formulaCallExprResult, formulaVarSetExprEval, formulaFormulaRules, formulaVarsOrder,
formulaVarExpressionSource, formulaVarExpressionCode, formulaVarExpressionEvaluation, formulaVarExpressionResult, and formulaVarFiltersResult.
Versioning Report (diff of two DTSes)
/rest/xbrl/​diff Diff two DTSes, producing an XBRL versioning report relative to report directory.
Parameters are requred “?” character, and are separated by “&” characters,
as follows:
fromDTS File name or url of from DTS.
toDTS File name or url of to DTS.
report File name or url of to report (to for relative path construction). The report is not written out, but its contents are returned by the web request to be saved by the requestor.
Example: /rest/​diff?​fromDTS=c:/a/prev/old.xsd&​toDTS=c:/a/next/new.xsd&​report=c:/a/report/report.xml: Diff two DTSes and produce versioning report.
Views
/rest/xbrl/​{file}/​{view} View document at {file}.
{file} may be local or web url, and may have “/” characters replaced by “;” characters (but that is not necessary).
{view} may be DTS, concepts, pre, cal, dim, facts, factTable, or formulae.
Example: /rest/​xbrl/​c:/a/b/c.xbrl/​dim?​media=html: View dimensions of
document at c:/a/b/c.xbrl (on local drive) and return html result.
/rest/xbrl/​view (Alternative syntax) View document, file and view are provided as parameters (see below).
Example: /rest/​xbrl/​view​?file=c:/a/b/c.xbrl&​view=dim​&media=xml: Validate entry instance
document at c:/a/b/c.xbrl (on local drive) and return structured xml results.
Parameters are optional after “?” character, and are separated by “&” characters,
as follows:
media html or xhtml: Html text results. (default)xml: XML structured results. json: JSON results. csv: CSV text results (no markup).
file Alternate way to specify file name or url by a parameter.
view Alternate way to specify view by a parameter.
import A list of files to import to the DTS, such as additional formula
or label linkbases. Multiple file names are separated by a ‘|’ character.
factListCols A list of column names for facts list. Multiple names are separated by a space or comma characters.
Example: factListCols=​Label,unitRef,Dec,​Value,EntityScheme,​EntityIdentifier,​Period,Dimensions
Excel interface
GUI operation: Select data tab.
Click Get External Data From Web.New Web Query dialog, enter rest URI to Address (example, for instance with indicated fact columns:
http://localhost:8080/rest/xbrl/C:/Users/​John Doe/​Documents/eu/​instance.xbrl/facts​?media=xhtml&factListCols=​Label,unitRef,Dec,​Value,EntityScheme,​EntityIdentifier,​Period,DimensionsBefore clicking Go, click Options, on Options dialog select Full HTML Formatting, then Ok to Options dialog.Click Go.Click arrow to select table.Click Import button.Review insertion cell, click ok on Import Data dialog.
VBA macro: With ActiveSheet.QueryTables.Add(Connection:= _"URL;http://localhost:8080/rest/xbrl/C:/Users/​John Doe/​Documents/eu/​instance.xbrl/facts​?media=xhtml&factListCols=​Label,unitRef,Dec,Value,​EntityScheme,EntityIdentifier,​Period,Dimensions" _
, Destination:=Range("$A$1"))
.Name = "facts"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
QuickBooks interface
Setup: Install QuickBooks Web Connector by clicking here.Click on QuickBooks.qwc in the Program Files Arelle directory, to install web connector for Arelle. (It specifies localhost:8080 in it.)Open your QuickBooks and desired companyFrom start menu, programs, QuickBooks, start Web ConnectorStart Arelle web server (if it wasn’t already running)

To request xbrl-gl, select report type (generalLedger, journal, or trialBalance) and specify file name for xbrl-gl output instance:

Example: http://localhost:8080/rest/quickbooks/generalLedger/xbrl-gl/C:/mystuff/xbrlGeneralLedger.xbrl/view?fromDate=2011-01-01&toDate=2011-12-31
(You may omit /view.)
Parameters follow “?” character, and are separated by “&” characters,
as follows:
media html or xhtml: Html text results. (default)xml: XML structured results.json: JSON results.text: Plain text results (no markup).
fromDate, toDate From & to dates for GL transactions
Management
/rest/configure Configure settings:
Parameters are required following “?” character, and are separated by “&” characters,
as follows:
proxy Show or modify and re-save proxy settings:Enter ‘show’ to view current setting, ‘system’ to configure to use system proxy setting, ‘none’ to configure for no proxy, or ‘http://[user[:password]@]host[:port]’ (e.g., http://192.168.1.253, http://example.com:8080, http://joe:secret@example.com:8080).” ))
plugins Show or modify and re-save plug-ins configuration:Enter ‘show’ to view plug-ins configuration, , or ‘|’ separated modules:
+url to add plug-in by its url or filename (relative to plug-in directory else absolute), ~name to reload a plug-in by its name, -name to remove a plug-in by its name,
(e.g., ‘+http://arelle.org/files/hello_web.py’, ‘+C:\Program Files\Arelle\examples\plugin\hello_dolly.py’ to load,
~Hello Dolly to reload, -Hello Dolly to remove). (Note that plug-ins are transient on Google App Engine, specify with &plugins to other rest commands.)
packages Show or modify and re-save taxonomy packages configuration:Enter ‘show’ to view packages configuration, , or ‘|’ separated package URLs:
+url to add package by its full url or filename, ~name to reload a package by its name, -name to remove a package by its name.
(Note that packages are transient on Google App Engine, specify with &packages to other rest commands.)
environment Show host environment (config and cache directories).

Java integration sample (load and validate)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class LoadValidate {
 public static void main(String[] args) throws IOException {
  String restAPIstr =
   "http://localhost:8080/rest/xbrl/" +
   "C:/Users/John%20Doe/Samples/instance0010000.xbrl" +
   "/validation/xbrl?media=text";
  URL url = new URL(restAPIstr);
  HttpURLConnection conn =
        (HttpURLConnection) url.openConnection();
  if (conn.getResponseCode() != 200) {
      throw new IOException(conn.getResponseMessage());
  }
  // Buffer the result into a string
  BufferedReader rd = new BufferedReader(
        new InputStreamReader(conn.getInputStream()));
  StringBuilder sb = new StringBuilder();
  String line;
  while 1)line = rd.readLine( != null) {
      sb.append(line);
   System.out.println(line);
  }
  rd.close();
  conn.disconnect();
 }
}

C# integration sample (load and validate)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Diagnostics;
namespace ArelleCsharpProject
{
    class LoadValidate
    {
        static void Main(string[] args)
        {
      string restAPIstr =
       "http://localhost:8080/rest/xbrl/" +
       "C:/Users/John%20Doe/Samples/instance0010000.xbrl" +
       "/validation/xbrl?media=text";
            HttpWebRequest req = WebRequest.Create(restAPIstr) as HttpWebRequest;
            string line;
            using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(resp.GetResponseStream());
                while 2)line = reader.ReadLine( != null)
                    Debug.WriteLine(line);
            }
        }
    }
}

References   [ + ]

1. line = rd.readLine(
2. line = reader.ReadLine(
 

Comments are closed.