> For the complete documentation index, see [llms.txt](https://docs.videc.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.videc.de/june5-3.7/en/web-api/web-api-client-code-beispiele/python-code-beispiele.md).

# Python Code Examples

The following code examples are scripted with *Python*.

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># For testing you can use the portal server at https://portal.videc.info
To insert Fiddler in between, you can use the following address:
http://localhost.fiddler:20000/api/v3.6/         or
http://machine-name.fiddler:20000/api/v3.6/
This script authenticates against the JUNE5 API and retrieves only some information
If "requests" is not installed: pip install requests
import requests
MyUser = 'admin'
MyPwd = 'admin'
MyBase = "https://portal.videc.info/api/v3.6/"
Create session
sess = requests.Session()
Get version
MyVersion = sess.get(f"{MyBase}System/GetVersion").json()
print(f"The following JUNE5 version is used: {MyVersion}")
print()
Authentication
Body = {
'Logon': 'admin',
'Password': 'admin',
'LoginType': 0
}
response = sess.post(f"{MyBase}auth/authenticate", data=Body)
MyJUNE5 = response.json()
print()
print(f"001 - Token String    = {MyJUNE5['Token']}")
print()
print(f"002 - Token Identity  = {MyJUNE5['IdentityToken']}")
print()
print(f"003 - Client Uid               = {MyJUNE5['IdentityToken']['ClientUid']}")
print()
print(f"004 - DataSource Read          = {MyJUNE5['IdentityToken']['DataSourceRead']}")
print()
print(f"005 - DataSource Read / Hidden = {MyJUNE5['IdentityToken']['DataSourceRead']['Hidden']}")
print()
print("End")
</code></pre></td></tr></tbody></table>

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># This Python script authenticates against the JUNE5 API and retrieves the object list
Here: Retrieval of objects of type "Measurement variable Auto" (code 16)
All objects or only certain object types can be queried
Further information can be queried for each object.
SV = Standard View
import requests
Define base data, configuration
MyUser = 'admin'
MyPwd = 'admin'
MyBase = "https://portal.videc.info/api/v3.6/"
1. Login and get token
MyAuthUrl = f"{MyBase}/auth/authenticate"
payload = {'Logon': MyUser, 'Password': MyPwd}
response = requests.post(MyAuthUrl, data=payload)
response.raise_for_status()  # (Raise error if login fails)
MyJ5Auth = response.json()
token = MyJ5Auth.get('Token')
2. Get data from GetList
list_url = f"{MyBase}/ViewModel/GetList?viewModelStrongName=SV"
headers = {'June5-Token': token}
data_response = requests.get(list_url, headers=headers)
data_response.raise_for_status()
my_data = data_response.json()
3. Process and filter data
print(f"{'Created':&#x3C;25} {'DataSourceKey':&#x3C;40} {'UID':&#x3C;40} {'UidCreated'}")
print("-" * 120)
for item in my_data:
# Filter: Only objects of type 16 (e.g. measurement variables type Auto)
if item.get('ObjectModelType') == 16:
# Access nested attributes
created = item.get('ObjectPermission', {}).get('Created', 'N/A')
ds_key = (item.get('DataSourceKey') or '').ljust(40)
uid = item.get('Uid', 'N/A')
uid_created = item.get('Object', {}).get('UidCreated', 'N/A')
    print(f&#x26;quot;{created:&#x26;lt;25} {ds_key} {uid:&#x26;lt;40} {uid_created}&#x26;quot;)
print()
print("End")
'''
Available columns
ShortAndLongName           // Short and long name
LongAndShortName           // Long and short name
ClientUid                  // Tenant ID
Uid
Name
DataSourceKey              // Unique "hard" key
ParentUid                  // For hierarchies the parent element
Object
ObjectModelType            // See below
ObjectModelItemUid
Items
ItemCount
HierarchyLevel
RootViewUid
DataSourceType             // See below
SortIndex
ObjectPermission           // Access rights
ObjectModelType                 Hex              Dec
None                         0x00000000      0
Custom                         0x00000001      1
Root                         0x00000002      2
Group                         0x00000004      4
DataSource                 0x00000008      8
ProcessVariable                 0x00000010      16
ProcessVariableCalculated     0x00000020      32
ProcessVariableManual         0x00000040      64
Report                         0x00000080      128
Chart                         0x00000100      256
Spare01                         0x00000200      512
View                         0x00000400      1024
DataKindInformation         0x00000800      2048
UrlObject                 0x00001000      4096
PieChart                 0x00002000      8192
CarpetChart                   0x00004000      16384
FrequencyChart                 0x00008000      32768
SankeyChart                 0x00010000      65536
ReportFilter                 0x00020000      131072
DashBoard                 0x00040000      262144
SingleValueObject         0x00080000      524288
GaugeChart                 0x00100000      1048576
TableObject                 0x00200000      2097152
Alarm                         0x00400000      4194304
AlarmTable                 0x00800000      8388608
ReportWidget                 0x01000000      16777216
AggregateQuery                 0x08000000      134217728
TrafficLight                 0x02000000      33554432
ManualValueTable         0x04000000      67108864
// Batch
Batch                         0x10000000      268435456
UnitBatchDefinition         0x20000000      536870912
BatchObject                 0x40000000      1073741824
UnitBatch                 0x80000000      2147483648
// WebReporting
WebReport                 0x1000000000      68719476736
MapMonitor                 0x100000000      4294967296
MapMonitorDynamicTrace         0x200000000      8589934592
MapMonitorStaticTrace         0x400000000      17179869184
MapMonitorStaticPoint         0x800000000       34359738368
DataSourceType = Source type
None = 0
June5 = 1
Acron = 2
June5Connector = 3
June5BatchConnector = 4
OpcUa = 10
OsiPi = 20
Ge = 30
WinCC = 40
SqlOleDb = 50
Phd = 60
Heb = 70
'''
</code></pre></td></tr></tbody></table>

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># This Python script authenticates against the JUNE5 API and
# retrieves the measurement value time series of a variable for a defined time period
import requests
import json
import time
Define base data
MyUser = 'admin'
MyPassword = 'admin'
MyBase = "https://portal.videc.info/api/v3.6/"
Login and get token
print("Login")
response = requests.post(
f"{MyBase}auth/authenticate",
data={"Logon": MyUser, "Password": MyPassword}
)
MyJUNE5 = response.json()
print(MyJUNE5['Token'])
print()
print("Wait 2 seconds")
time.sleep(2)
print()
Define request payload
ReqPay = {
'Parameters': [
{
'DataSourceKey': 'J5001DE.TA',
'From': '2025-01-01T00:00:00.000',
'To': '2025-01-02T01:00:00.000',
'DataKind': '0',    # 0=Pro, 1=Int1, 2=Int2, ...,20=Day, 50=Week, 51=Month, 52=Year, 300=Manual
'ValueKind': '0',   # 0=VAL, 5=PMIN, 6=PMAX...
'Resolution': '0',  # -1, 2000
        # Optional parameters:        # &#x26;#x27;ObjectModelStrongName&#x26;#x27;: &#x26;#x27;string&#x26;#x27;,        # &#x26;#x27;ObjectModelItemUid&#x26;#x27;: &#x26;quot;00000000-0000-0000-0000-000000000000&#x26;quot;,        # &#x26;#x27;Handle&#x26;#x27;: &#x26;quot;00000000-0000-0000-0000-000000000000&#x26;quot;,        # &#x26;#x27;OrderBy&#x26;#x27;: &#x26;quot;true&#x26;quot;,        # &#x26;#x27;IgnoreNullValues&#x26;#x27;: &#x26;#x27;true&#x26;#x27;    }]
}
Create JSON
JSON = json.dumps(ReqPay, indent=2)
print("This is what the JSON object (payload of the request) looks like")
print(JSON)
print()
Query a variable
response = requests.post(
f"{MyBase}ViewModel/GetProcessVariableListValuesByDataSourceKey",
headers={
"June5-Token": MyJUNE5['Token'],
"Content-Type": "application/json"
},
data=JSON
)
The entire response is now available as a JSON object and can be processed or output further
print(response.json())
MyLists = response.json()
MyObjectList  = MyLists['ObjectList']
print("Here are the values:")
for item in MyObjectList:
for value in item['Values']:
print(value['Timestamp'], ';', value['Value'])
print()
print("End")
</code></pre></td></tr></tbody></table>

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># This script authenticates against the JUNE5 API and retrieves the measurement value time series of multiple measurement variables
# Note: The time period can be different for each measurement variable
import requests
import time
import json
Define base data
MyUser = 'admin'
MyPwd = 'admin'
MyBase = "https://portal.videc.info/api/v3.6/"
1. Login and get token
print(f"Login with: {MyUser}\n")
MyAuthUrl = f"{MyBase}/auth/authenticate"
payload = {"Logon": MyUser, "Password": MyPwd}
response = requests.post(MyAuthUrl, data=payload)
response.raise_for_status()  # Raise error if request fails
MyJ5Data = response.json()
token = MyJ5Data.get("Token")
print(f"Token: {token}\n")
2. Wait
print(f"Wait 2 seconds\n")
time.sleep(2)
3. Define request payload (dictionary in Python)
req_pay = {
"Parameters": [
{
"DataSourceKey": 'J5001DE.TA',
"From": '2025-01-01T00:00:00.000',
"To": '2025-01-04T00:00:00.000',
"DataKind": '0',
"ValueKind": '0',
"Resolution": '2000',
"IgnoreNullValues": 'true'
},
{
"DataSourceKey": 'J5001DE.LD',
"From": '2025-02-01T00:00:00.000',
"To": '2025-02-04T00:00:00.000',
"DataKind": '0',
"ValueKind": '0',
"Resolution": '2000'
}
]
}
print(f"This is what the JSON object of the request looks like: \n")
print(json.dumps(req_pay, indent=4))
print()
4. Execute query
data_url = f"{MyBase}/ViewModel/GetProcessVariableListValuesByDataSourceKey"
headers = {
"June5-Token": token,
"Content-Type": "application/json"
}
data_response = requests.post(data_url, headers=headers, json=req_pay)
data_response.raise_for_status()
my_data = data_response.json()
5. Output all variables and data
print(f"Output of all variables and the data TimeStamp, Value\n")
object_list = my_data.get("ObjectList", [])
total_count = 0
for var in object_list:
# String concatenation (f-strings from Python 3.6)
header = f"{var.get('DataSourceKey')} ({var.get('Name')}) [{var.get('ProcessUnit')}]"
print(header)
values = var.get(&#x26;quot;Values&#x26;quot;, [])for item in values:    print(f&#x26;quot;{item.get(&#x26;#x27;Timestamp&#x26;#x27;)};{item.get(&#x26;#x27;Value&#x26;#x27;)}&#x26;quot;)    total_count += 1print()
print(f"Number of values of all variables\n")
print(total_count)
</code></pre></td></tr></tbody></table>

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># This Python script authenticates against the JUNE5 API and
# retrieves the users
import requests
Define base data, configuration
MyUser = "admin"
MyPwd = "admin"
MyBase = "https://portal.videc.info/api/v3.6/"
sess = requests.Session()
Step 1: Login and get token
print("Step 1: Login")
r = sess.post(
f"{MyBase}auth/authenticate",
data={"Logon": MyUser, "Password": MyPwd, "LoginType": 0},
timeout=30,
)
r.raise_for_status()
MyJUNE5 = r.json()
Token = MyJUNE5.get("Token")
if not Token:
raise RuntimeError("No token received (login failed or response unexpected)")
print("Token:", Token)
print()
Step 2: Get user list
print("Step 2: Get user list")
r = sess.get(
f"{MyBase}UserAdministration/GetUsers",
params={"userType": "0"},
headers={"June5-Token": Token},
timeout=30,
)
r.raise_for_status()
MyData = r.json()
print()
Step 3: Output
print("Step 3: Output")
print()
print("Number of users:", len(MyData))
print()
print("Logonname; LastName; Firstname; IsEnabled")
for u in MyData:
print(f"{u.get('Logon')}; {u.get('LastName')}; {u.get('Firstname')}; {u.get('IsEnabled')}"
)
Other important fields are 'Uid' and 'UidCreated' to determine who created or modified which object.
print()
print("End")
</code></pre></td></tr></tbody></table>

|   |   |
| - | - |

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code># This Python script authenticates against the JUNE5 API and
# retrieves a PDF report
#
# Process:
#   Step 1: Login and get token
#   Step 2: Determine the measurement variable list, but only report objects (ObjectModelType 128) via GetListPaged (OData)
#   Step 3: With a report UID, get the PDF stream (PrintReportExt) and save as file
#
# Notes:
#   - OData query parameters are: $filter, $top, $skip, $orderby
#   - In PowerShell, "$" was escaped; in Python we pass the parameters directly as keys
#   - In addition to the header token, the token is also passed as a query parameter june5Token (as in PS)
import requests
Define base data
MyUser = "admin"
MyPwd = "admin"
MyBase = "https://portal.videc.info/api/v3.6/"
sess = requests.Session()
Step 1: Login and get token
print("Step 1: Login with token")
r = sess.post(
f"{MyBase}auth/authenticate",
data={"Logon": MyUser, "Password": MyPwd, "LoginType": 0},
timeout=30,
)
r.raise_for_status()
MyJUNE5 = r.json()
Token = MyJUNE5.get("Token")
if not Token:
raise RuntimeError("No token received (login failed or response unexpected)")
print("Token:", Token)
print()
headers = {"June5-Token": Token}
Step 2: GetListPaged -> only reports (ObjectModelType 128)
print("Step 2: Determine the measurement variable list, but only report objects of type 128")
params = {
"$filter": "ObjectModelType eq Videc.June5.Entities.ObjectModelType'128'",
"$top": "500",
"$skip": "0",
"$orderby": "DataSourceKey asc, Name asc",
}
r = sess.get(
f"{MyBase}ViewModel/GetListPaged",
params=params,
headers=headers,
timeout=60,
)
r.raise_for_status()
MyData = r.json()
items = MyData.get("Items") or []
print("Found report items:", len(items))
if not items:
raise RuntimeError("No report items found (Items is empty)")
UID of the first report (as in the PowerShell example)
MyPDFReportUID = items[0].get("ObjectModelItemUid")
if not MyPDFReportUID:
raise RuntimeError("First item has no ObjectModelItemUid")
print("Report UID (first item):", MyPDFReportUID)
print()
Step 3: PrintReportExt -> get PDF stream and save as file
print("Step 3: Get PDF stream and save as file")
For PrintReportExt, all parameters must be specified (like in PS)
params = {
"june5Token": Token,
"uid": MyPDFReportUID,
"from": "2022-05-01T00:00:00.000",
"to": "2022-06-01T00:00:00.000",
"widthIntervall": "60",
"filterName": "",
"isPlantFilter": "true",
}
r = sess.get(
f"{MyBase}ViewModel/PrintReportExt",
params=params,
headers=headers,
timeout=60,
)
r.raise_for_status()
out_file = "MyReport2.pdf"
with open(out_file, "wb") as f:
f.write(r.content)
print("PDF saved:", out_file)
print()
print("End")
</code></pre></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.videc.de/june5-3.7/en/web-api/web-api-client-code-beispiele/python-code-beispiele.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.
