Generated documentation, of the gitHub source code API, is available at: API Documentation.

The Python API requires a Controller (subclass of to initiate modelManager operations.  The controller must have two feedback methods, addToLog (for messages) and showStatus(for status messages if they are desired). will be explained to demonstrate the minimum API:

modelManager = ModelManager.initialize(self)

Initializes the model manager, and provides the calling instance (self), needed for the callbacks to addToLog and showStatus.

filesource = FileSource.FileSource(“c:\test\abc.xsd”)

A filesource instance is a wrapper for files that may be ordinary files or zip/xfd/frm archive files.  If the file is not an archive, the filesource just retains the file path, but if it is an archive, then contents of the archive (such as an instance document to read first) can be specified by the“instance.xml”) method.


Select calculation linkbase checks, inferring decimals, to be performed by validate operation.


Select calculation linkbase checks, inferring precision, to be performed by validate operation.

modelManager.validateDisclosureSystem = True

Used to inform the modelManager when Disclosure System rules validation (such as U.S. SEC Edgar or Japan FSA) is desired.  Must be set before loading an entry point document.  Edgar Filing Manual and Global Filing Manual are currently implemented.“efm”)

Used to select which disclosure system rules to apply (e.g., U.S. SEC Edgar, Japan FSA).  The parameter must match one of the disclosure system names in the file lib/disclosuresystems.xml.  For example, the file entry names=”Japan FSA|jp-fsa|fsa” means that any of the these three name alternatives would specify the Japan FSA rule set.


Select Unit Type Registry validation is to be performed by the validate operation.

modelManager.load(filesource, “subsequent action”)

Asks the modelManager to load the entry point specified by the filesource.  If successful, the prompt specified by the second argument will be displayed to the showStatus callback method.


Performs validation applicable to the entry point (including that specified by the validateSEC option, if entry file is an instance or DTS).  Any errors and other messages are provided to the addToLog callback method.


Closes the last-opened entry point and releases resources.

To compare two DTSes and produce a versioning report, please replace modelManager.validate(), above, with these:

modelManager.load(diffFilesource, _(“views loading”))

The first .load represents the fromDTS, the second .load represents the toDTS.   The file name provided by compareDTSes is that used to save the versioning report.

Note that two entries were loaded, so there should be two modelManager.close() calls, which act in LIFO manner to close the corresponding .load()’ed entry.

Development Environment

There are several excellent Python-based development environments.  Many XBRL practitioners have spent their lives with Java; they can use  Eclipse, configured for Python (pydev), which is compatible with Arelle.


12 Responses to API, Python

  1. ding says:

    Hi, I’m new to python.

    Try to write code as instructed in the “API” section, created a controller, but then ran into the “_” problem: global name ‘_’ is not defined

    import gettext, time, datetime
    import xml.dom.minidom, xml.parsers.expat, os
    from arelle import (Cntlr, FileSource, ModelManager, ModelXbrl, ModelDocument, XmlUtil, Version)
    from arelle import (XbrlConst, XmlUtil, UrlUtil, ModelObject, ValidateFilingText, XmlValidate)
    from arelle.ModelValue import (qname)

    def main():

    class ArelleCntlrSample(Cntlr.Cntlr):
    def __init__(self):

    def run(self):
    self.messages = []
    modelManager = ModelManager.initialize(self)
    filesource = FileSource.FileSource(“L:\\home\\research\\xbrl\\us-gaap\\samples\\Marriott_20110617\\mar-20110617.xml”)
    modelManager.load(filesource, _(“views loading”)) ### not working need to expand

    def addToLog(self, message):
    if self.messages is not None:
    self.messages.append(message + ‘\n’)
    print(message) # allows printing on standard out

    def showStatus(self, message, clearAfter=None):

    if __name__ == “__main__”:

  2. hephaestus says:

    The API Documentation page at (redirected from contains only a listing of the modules in the Arelle package. There are no links from any of the items in the module listing to the corresponding module contents.

    Configuration or build problem, perhaps?

  3. Gauss says:

    How to get ModelDocument object

    I want to get ModelDocument object, so I write the code below. But it returns Error1.
    What’s wrong with me?

    def __init__(self):

    def run(self):
       URL = ""
       filesource = FileSource.FileSource(URL)
       modelXbrl = self.modelManager.load(filesource)
       K1 = ModelDocument.load(modelXbrl, filesource)

    AttributeError: ‘FileSource’ object has no attribute ‘startswith’

    This URL is XBRL Instance Document of Western Digital 10-K report of June 27, 2014 in SEC filings.

  4. Peter says:

    Could it be that the API doc is again only listing module names? Would it be possible to fix that again?


    • admin says:

      Yes, we want to add more markup descriptions to the source for the API doc. However the plate of tasks to do is always overflowing.

  5. Chuck says:

    Is running under IronPython supported?

    • admin says:

      Not yet, Arelle depends on lxml, which as far as I know isn’t yet ported to iron python nor is there any close equivalent. There are other modules also needed for specific other features but their absence wouldn’t affect core product operation (e.g., formula requires pyparsing, EdgarRenderer requires a large number of libraries not on iron python, etc).

  6. Aman says:


    I am unable to pip install the arelle package and thus unable to import it. Where do I get the arelle package from to use the Python API.
    Please help.


Leave a Reply

Your email address will not be published. Required fields are marked *