The Python Script for API Task package enables users to import and execute Python scripts using API Tasks. This package leverages the Python library support within API Tasks to implement complex data processing, mathematical computations and machine learning capabilities using API Tasks.

Overview

The Python Script for API Task package contains actions that executes Python scripts or a specific function within the script. The workflow sequence for executing Python script is as follows:

  1. Define the source Python script and session name using the Open action.
  2. Execute the script using one of the following actions:
    • Execute function: Use when executing a specific function within the script.
    • Execute script: Use when executing the entire script.
    The Execute actions use the session name defined in the Open action to fetch the source Python script.
  3. Close the Python Script session using the Close action.

The package utilizes the Wasmer Python library integrated into the API Task runtime. The following Python libraries are supported:

Libraries Note
  • math
  • json
  • re
  • itertools
  • functools
  • datetime
Fully supported.
  • pandas (Pyodide build)
  • numpy (Pyodide build)
Both libraries require WASM wheels to be installed on the local machine.
  • requests
  • httpx
Both libraries require WASIX to be installed and networking enabled on the local machine.
  • beautifulsoup4
  • lxml (Pyodide build)
lxml requires WASM to be installed on the local machine.
  • asyncio
  • aiohttp
aiohttp requires WASIX to be installed on the local machine.
  • tqdm
  • rich
Fully supported.
Note: The Python Script for API Task does not support hot bot mode.

Actions in Python Script for API Task package

The following actions are available in this package

Action Description
Open

The Open action defines the source Python and creates a session for executing Python scripts

Open action.

Execute function

The Execute function action executes a specific function within the Python script defined in the Open action.

Execute function action.

For an example, see Example of using Python script to join a list.

Execute script

The Execute script action executes the Python script defined in the Open action.

See Execute script action.

For an example, see Example of creating a PDF using Python script.

Close

The Close action closes the session.

See Close action.