Skip to main content

Event hub listener

At a basic level, and this is the way Connect and integrations communicate with the rest of ftrack platform, integrating with the ftrack event hub is a powerful way to listen to events and react to them.

Event plugin path

At launch, the Python API will search the FTRACK_EVENT_PLUGIN_PATH for plugins having a register function. This function is where you can use the provided session object to listen to events and react to them.

info

This is the way Connect picks up plugins - by appending all hook folders found to the FTRACK_EVENT_PLUGIN_PATH.

You can also provide action listeners that brings up custom interfaces within Studio, aided by the ftrack Action Handler

Creating your own listener

The easiest way is to create a Connect plugin that listens to events and reacts to them. A good example is the locations recipe.

For servers and other headless environments were it is not possible to run Connect, follow these guidelines:

  1. Create a Python(3+) virtual environment and install the ftrack Python API: pip install ftrack-python-api
  2. Create a new Python file and import the ftrack Python API, then create a session object and add your logic to listen to events.
  3. Set the required environment variables:
    • FTRACK_SERVER - the URL to the ftrack server
    • FTRACK_API_KEY - the API key
    • FTRACK_API_USER - the API user
  4. Run the Python file from your environment.
tip

Utilise supervisordon a Linux server to easily boostrap your event listener on server start.

Resources

For detailed information on how the ftrack Python API works, please refer to earlier parts in this Developer hub, the recipes in this section or head over to the ftrack Python API Github repository.