Skip to main content
Skip table of contents

Invoking A Data Lab Functions REST API Endpoint

API Endpoint URL Structure

The API endpoint URL follows a well-defined structure, allowing users to access specific functionalities within Data Lab. The URL is composed of several components:

  1. {protocol}: Refers to the protocol used for communication, such as "http" or "https."

  2. {seeq_server}: Represents the address of the Seeq server, which hosts the Data Lab environment.

  3. {project_uuid}: Unique identifier for the Data Lab project that contains the desired Jupyter notebook.

  4. functions/notebooks/{notebook_name}/endpoints/{endpoint_path}: Specifies the path to the API endpoint within the Jupyter notebook.

  5. {query_string}: Optional query parameters that can be passed to the API for further customization.

Example Endpoint URL:

Let's break down a sample API endpoint URL:

CODE
https://develop.seeq.dev/data-lab/75744496-4887-4531-93CD-88DD03524544/functions/notebooks/workbook_migration/endpoints/migrate?workbook_name=Test%20Analysis
  • https://develop.seeq.dev: This part represents the Seeq server's address and port number.

  • /data-lab/75744496-4887-4531-93CD-88DD03524544: The Data Lab project UUID uniquely identifies the specific project.

  • /functions/notebooks/workbook_migration/endpoints/migrate: This path points to the endpoint named "migrate" within the "workbook_migration" Jupyter notebook.

  • ?workbook_name=Test%20Analysis: An optional query parameter, "workbook_name," is provided as part of the URL.

Executing Data Lab Functions via API

Users and developers can now perform a variety of operations by sending HTTP requests to the custom API endpoints defined within Jupyter notebooks. These operations can include data analysis, visualization, model execution, and much more.

Headers/Cookies

Seeq Headers

Data Lab Functions request must include an authentication token header or cookie but can include optional consumption headers.

  • sq-auth / x-sq-auth (required)

    • Use sq-auth if supplied in cookie and x-sq-auth if supplied in header

    • The authentication token to a Seeq site

  • sq-origin-label (optional)

    • This header sets the displayed text for the data consumption record. The default value is the project name concatenated with the base notebook path. For example, Data Lab Functions Demo - DataLabFunctionsTest

  • sq-origin-url (optional)

    • This header sets the url that links to the consumption label. The default value is the URL to the notebook. For example: https://explore.seeq.com/data-lab/161EF9DD-5890-4630-94F8-CEE3E4834FB5/notebooks/DataLabFunctionsTest.ipynb

Custom Headers

You may add any other headers you wish to the Data Lab Functions request. Headers can be accessed in the REQUEST dictionary: REQUEST["headers"] A common use case would be to change the content type of the response. See Content Types

DataFrame Response

To return a pandas DataFrame from a Data Lab Functions endpoint, convert the DataFrame to a dictionary and return that from the endpoint. Then in the client create a DataFrame from the response json.

Server endpoint:

PY
# GET /test
df_json = df.to_json(orient='columns') # where df is the DataFrame you want to return
response = json.loads(df_json)
response

Python client:

PY
response_json = response.json()
df = pd.DataFrame(response_json)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.