The Python data source is one of the integration methods available on the Kuika platform that allows you to develop custom functions and business logic. Using Python, you can define custom operations within your application, create functions that accept parameters, and use these functions in application workflows.
With the Python data source, you can write custom code to address needs beyond the built-in actions, customize data processing workflows, and create reusable functions.
Add a Data Source Connection to Your Application Using Python
Log in to the Kuika platform and open the project you’ll be working on from the Apps screen.
Open the Datasources module from the top menu.
On the Datasources screen that opens, you can view your existing data sources under the Recently modified and Data sources tabs, and search using the Search by name field.
Click the Create a Function card among the cards at the top of the screen. This card allows you to create custom functions using C#, TypeScript, Python, Java, Go, and Rust.
From the Development list that opens, select the Python (Custom Python functions) option. You can use the ↑/↓ keys to navigate the list and the Enter key to make a selection.
Enter a name for your data source in the Name field (e.g., userguidepython).
Click the CREATE button to complete the process. To cancel the process, use the CANCEL button; to return to the language selection, use the < Python link.
Note: You can also start the process of adding a new data source by clicking the + icon next to the Sources heading in the left panel.
Anatomy of the Python Editor Screen
A. Top Menu
Back Button (←): Takes you back to the Datasources screen.
Data Source Name: The name of the Python data source you created (e.g., userguidepython) is displayed alongside the Python icon. You can switch between data sources using the drop-down arrow next to it, or edit the name using the pencil icon.
CREATE Button: Used to save the Python data source you’ve created.
B. Editor Toolbar
Undo / Redo: Allows you to undo or redo changes you’ve made.
Copy / Paste: Used to copy code and paste it into the editor.
Tidy Up Code: Use the magic wand icon to format, align, and make your code more readable.
Word Wrap: Turns word wrap on or off so that long lines wrap to the next line based on the editor’s width.
Font Size (− 12 +): Lets you increase or decrease the font size in the editor; you can return to the default size using the icon next to it.
External Libraries (BETA): A drop-down menu that lets you add external libraries to use in your Python code. It is currently labeled as BETA.
Python Version: A drop-down menu that lets you specify which Python (CPython) version your code will run on. Supported versions:
CPython 3.14.6
CPython 3.13.14
CPython 3.12.13
CPython 3.11.15
CPython 3.10.20
By default, the latest version (CPython 3.14.6) is selected; you can choose an older version as needed. The green checkmark icon next to the menu indicates that your code is valid for the selected version.
C. Python Editor
This is the code editing area. All custom functions are defined here.
Default example structure:
python
defnew_function(parameter1: str) -> str:# Your code herereturn parameter1
This structure demonstrates the following:
Functions are defined using the `def` keyword.
They can accept parameters.
The parameter type can be specified using a type hint (: str).
The return type can be defined as -> str.
The area where you will write your code is marked by a comment line (# Your code here) within the function body.
D. Kuika AI Panel
This is the AI assistant located on the right side of the screen. By typing your needs into the Type here... field, you can receive code suggestions for your Python actions and make use of examples.
E. Test Console
This area, located at the bottom of the screen, is used to test the functions you’ve written. It can be opened and closed using the arrow on the right.
In this section:
The function list is displayed.
Parameter input fields are provided.
The output result can be viewed.
Configuring Python Data Source Settings
Manual Code Writing
You can manually write your code directly in the editor.
You can generate code automatically by entering a description in the Kuika AI field on the right panel.
Example command:
Create a function that converts the entered text to uppercase.
Selecting a Python Version
You can select the CPython version your code will run on from the PYTHON dropdown menu on the toolbar (see python_2.png and python_1.png). Since language features or library compatibility may vary between different versions, it is recommended that you select the version appropriate for your project’s needs.
Using External Libraries (BETA)
External Libraries allows you to include additional packages in your project beyond the standard Python libraries via the dropdown menu. This feature is currently in BETA.
This function takes two numbers and returns their sum.
Specifying the Return Type
The data type to be returned must be specified in the function definition using the -> symbol. Example types: str, int, float, bool, dict, list, Any.
Testing Functions with the Test Console
After writing your code, you can open the Test Console section at the bottom to use it.
Select the function you want to test.
Enter sample data into the parameter fields.
Run the function.
Check the returned result.
Example:
python
defhello(name: str) -> str:return “Hello ” + name
Parameter: Kuika Expected output: Hello Kuika
Saving the Data Source with CREATE
After completing and testing your code, you can save the Python data source by clicking the CREATE button in the top-right corner. The saved data source becomes available for use within the application.
Expected Output / Result
Once these steps are completed:
The Python data source is added to the Sources list.
The defined functions become available for use in the system.