SAS ESPPy Library
for developers

Getting started with SAS ESPPy

The ESPPy package enables you to create SAS Event Stream Processing (ESP) models programmatically in Python. Using ESPPy, you can connect to an ESP server and interact with projects and their components as Python objects.


  • full integration with Jupyter notebooks
  • visualize diagrams of your ESP projects
  • support for streaming charts and images
  • easily embed an ESP project inside a Python pipeline

Try ESPPy for free!

  • explore the capabilities of SAS Event Stream Processing
  • self-contained programming environment - no installation
  • use JupyterLab as an interface
  • run Python code and work through pre-packaged examples

Sample code

The sample code below establishes a connection and loads a project. To see further sample code, visit the ESPPy examples page on GitHub.

Create a new ESP project

# Import the ESPPy package and create a connection

In [1] : import esppy
         esp = esppy.ESP('')
Out[2] : ESP('')

# Load a project
In [3] : %%sh
         cat model_walking.xml
    <project name='project' pubsub='auto' threads='1' use-tagged-token='true'>
        <contquery name='contquery' trace='w_data w_calculate'>
            <window-source name='w_data' insert-only='true'>
                  <field name='id'   type='int64' key='true'/>
                  <field name='time' type='double'/>
                  <field name='x'    type='double'/>
                  <field name='y'    type='double'/>
                  <field name='z'    type='double'/>
            <window-source name='w_request' insert-only='true'>
                  <field name='req_id'  type='int64' key='true'/>
                  <field name='req_key' type='string'/>
                  <field name='req_val' type='string'/>
            <window-calculate name='w_calculate' algorithm='Summary'>
                  <field name='id'     type='int64' key='true'/>
                  <field name='x'      type='double'/>
                  <field name='mean_x' type='double'/>
                  <field name='n_x'    type='int64'/>
                  <property name="windowLength">5</property>
                  <property name="input">x</property>
                  <property name="meanOut">mean_x</property>
                  <property name="nOut">n_x</property>
            <window-copy name="w_copy"/>
            <edge source='w_data'    target='w_calculate' role='data'/>
            <edge source='w_request' target='w_calculate' role='request'/>
            <edge source='w_calculate'    target='w_copy' role='data'/>