# Python programming

## How to run Python source code in Mavibot.ai

To run a source code (.py extension) the function **code\_executor(URL, params)** is used, where

**URL** - the url to the source code (“<https://mavibot.ai/handler.py”> as an example)

**params** - the parameters that are needed for your code (they come as a JSON line)

The returned value is what the function returns

Example:

![](https://lh5.googleusercontent.com/LS-DvyjzFkpV6FMf1xDu_lgBMle_VulqC6M2W1SIQdu_q7GzALODAfVzU4Xu41O-hk7_hRJvAxHL-GHzqWT5Gmn5WYntvr-KdmgxhBPqxxQ14l5Vs7cuPIkLEnisPcrFoCkLKiKfEky3VgOsDg)

{% hint style="success" %}
If you need to send API requests from a Russian IP address, we recommend using the Salebot proxy.

Example:

requests.get('<https://google.com>', proxies={'https': '[http://51.250.88.121:24532'}).text](https://docs.mavibot.ai/special-features/http:/51.250.88.121:24532'}\).text)
{% endhint %}

{% hint style="info" %}
`139.59.148.123` — Python code executor
{% endhint %}

**Requirements for the source code:**

Your code must include a handle(data) function that accepts a parameter containing a hash of the parameters you specified in the block settings. The function must return a value that will be passed back to the bot after execution. To split the result into the editor’s parameters, return it as JSON.

An example code you can see here: <https://mavibot.ai/handler.py>

You can use standard libraries, as well as those listed below:

requests \
logger \
gspread \
oauth2client \
numpy \
pyzbar \
fuzzywuzzy \
python-Levenshtein \
re \
urllib \
time \
json \
hmac \
hashlib \
beautifulsoup4 \
pandas \
base64 \
xmltodict \
mysql-connector-python \
zeep \
Google-api-python-client

### Video overview


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/special-features/python-programming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
