Introduction
This document provides detailed guidelines on using the integrated Python editor console within our platform. The editor is pre-configured with essential libraries and functionalities to assist in executing Python scripts effectively, particularly for data querying and handling secrets.Where to find the Python Editor Console?
- In the Create Metric page, click on the “Custom Query” option located at the top left side of the page.
- Then, choose
</> Pythonfrom the dropdown in the</> Query Editorpanel to access our Python Editor Console.

Pre-installed Libraries
- Requests Module: The
requestslibrary is readily available and pre-imported for HTTP requests.
You do not need to import it again in your scripts.
Working with Variables
To integrate dynamic data within your scripts, you can utilize predefined variables and data structures:- Client ID: Use the variable
client_idwhich should be a string representing the client identifier. - Metric Filters: This variable
metric_filtersallows for the filtering of data based on various criteria. The structure ofmetric_filtersis defined as follows:
metric_filters variable can include filters of types STRING, DATE, and NUMBER, uniquely identified by a filter name:
- STRING: A plain string value.
- DATE: A dictionary containing
startDateandendDate, both ofdatetime.datetype. - NUMBER: An integer value.
metric_filters is populated only when (1) the metric’s SQL query actually uses that filter variable (e.g. in a WHERE clause), and (2) the metric is run in a dashboard context where that filter is applied and the user has selected a value. If you see empty {} even when a filter is selected, check that the metric’s SQL references the filter variable by the exact name, and that you are running from a dashboard view with the filter applied—not from a standalone console or a metric that does not use the filter.
Handling Secrets
Secrets are stored and accessed via thesecrets dictionary. This allows secure storage and retrieval of sensitive data such as API keys or database credentials. You can set up your secrets in the Home Page → Settings Tab → Secrets.
Storing Results
To store or output data from your script, assign your data to theresultvariable. This variable should be an array of objects (or a list of dictionaries in Python terms):

