API functions

In addition to the magic commands, the pystata Python package also provides two modules, config and stata, to interact Stata with Python.

The config module is used to configure the system and display current system information and settings. The stata module contains core functions used to interact with Stata; for example, the functions can be used to run Stata commands, pass data between Stata and Python, and access Stata’s returned results.

Unlike the magic commands, these modules can be used in both IPython and non-IPython environments. For example, they can be used when accessing Python from a Jupyter Notebook or from a command line, such as Python’s IDLE, the Windows Command Prompt, a macOS terminal, or a Unix terminal. More importantly, the Stata Function Interface (sfi) module can be used together with these two modules, making it more convenient to access Stata’s core features.

Module summary