# Kepware Configuration API SDK for Python
[![Released Version](https://img.shields.io/pypi/v/kepconfig)](https://pypi.org/project/kepconfig) [![Supported Versions](https://img.shields.io/pypi/pyversions/kepconfig)](https://pypi.org/project/kepconfig) ![PyPI - Downloads](https://img.shields.io/pypi/dm/kepconfig) ![PyPI - License](https://img.shields.io/pypi/l/kepconfig)
This is a package to help create Python applications to conduct operations with the Kepware Configuration API. This package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP). For reference, Kepware Server in this documentation will refer to both TKS and KEP versions.
**API reference documentation is available on [Github Pages](https://ptcinc.github.io/Kepware-ConfigAPI-SDK-Python)**
## Prerequisites
Package supported and tested on Python 3.9 or later. Older versions support earlier Python 3 environments but have less functionality. All HTTP communication is handled by the [urllib](https://docs.python.org/3/library/urllib.html#module-urllib) Python standard library.
## Features
- Supports both HTTP and HTTPS connections with certificate validation options
Package allows for *GET*, *ADD*, *DELETE*, and *MODIFY* functions for the following Kepware configuration objects:
| Features | TKS/KEP | TKE |
| :----------: | :----------: | :----------: |
| **Project Properties** <br /> *(Get and Modify Only)* | Y | Y |
| **Connectivity** <br /> *(Channel, Devices, Tags, Tag Groups)* | Y | Y |
| **IoT Gateway** <br /> *(Agents, IoT Items)* | Y | Y |
| **Datalogger** <br /> *(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)* | Y | Y |
| **UA Gateway** <br /> *(Certificates, Server Endpoints, Client Connections, Server Interface parameters)* | Y*** | N |
| **Administration** <br /> *(User Groups, Users, UA Endpoints, Local License Server)* | Y* | Y |
| **Product Info and Health Status\*\*** | Y | Y |
| **Import Project (via JsonProjectLoad Service) / Export Project\*\*\*\***| Y | Y |
- Note (*) - UA Endpoints and Local License Server supported for Kepware Edge only
- Note (**) - Added to Kepware Server v6.13 / Kepware Edge v1.5 and later builds
- Note (***) - TKS only v6.16 and later
- Note (****) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds
Driver specific features:
| Driver | Features |
| :----------: | :----------: |
|GE Ethernet Global Data|Exchanges, Ranges and Name Resolutions|
|Universal Device Driver|Profile Library|
Methods to read the following logs:
| Logs | TKS/KEP | TKE |
| :----------: | :----------: | :----------: |
| **Event Log** | Y | Y |
| **API Transaction Log** | Y | Y |
Configuration API *Services* implemented:
| Services | TKS/KEP | TKE |
| :----------: | :----------: | :----------: |
| **TagGeneration** <br /> *(for supported drivers)* | Y | Y |
| **ReinitializeRuntime** | Y* | Y |
| **ProjectLoad and ProjectSave**| Y | Y |
| **JsonProjectLoad\*\*** <br /> *(used for import project feature)*| Y | Y |
Note (*) - Reinitialize service was implemented for Kepware Server v6.8+
Note (**) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds
Filtering, sorting and pagination query options are added for any collections methods (ex: `get_all_devices()` or `get_all_channel()`).
Generic REST methods are provided to use for functions not developed in SDK package. These are found in the `Server` class in [connection.py](./kepconfig/connection.py)
## Known Limitations
- Other property configuration for more complex drivers with objects besides channels, devices, tags and tag groups are not always explicitly defined
- Other supported plug-ins (EFM Exporter, Scheduler, etc) are not defined
- When using hostnames (not IP addresses) for connections, delays may occur under certain network configurations as the connection may attempt IPv6 connections first. IPv6 is not supported by Kepware servers at this time.
## Installation
Package can be installed with `pip` using the following:
```cmd
pip install kepconfig
```
## Key Concepts
**NOTE:** Detailed examples can also be found in the [examples](./examples/) folder.
### Create server connection instance
```python
from kepconfig import connection
server = connection.server(host = '127.0.0.1', port = 57412, user = 'Administrator', pw = '')
# For HTTPS connections:
server = connection.server(host = '127.0.0.1', port = 57512, user = 'Administrator', pw = '', https=True)
```
For certificate validation, the SDK uses the OS/systems trusted certificate store. The connection uses the `create_default_context()` function as part of urllib as described at the following links:
- [ssl.create_default_context](https://docs.python.org/3/library/ssl.html#ssl.create_default_context)
- [ssl.SSLContext.load_default_certs](https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_default_certs)
- [set_default_verify_paths](https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_default_verify_paths)
For Windows OSes, the Kepware Server's instance certificate can be loaded into the hosts "Trusted Root Certificate Authorities" store.
### Create an object
Objects such as channels or devices can be created either singularly or with children included.
### Ex: Add Single channel
```python
from kepconfig.connectivity import channel
channel_data = {"common.ALLTYPES_NAME": "Channel1","servermain.MULTIPLE_TYPES_DEVICE_DRIVER": "Simulator"}
result = channel.add_channel(server,channel_data)
```
### Ex: Add Multiple tags
```python
from kepconfig.connectivity import tag
tag_info = [
{
"common.ALLTYPES_NAME": "Temp",
"servermain.TAG_ADDRESS": "R0"
},
{
"common.ALLTYPES_NAME": "Temp2",
"servermain.TAG_ADDRESS": "R1"
}
]
tag_path = '{}.{}.{}'.format(ch_name, dev_name, tag_group_path)
result = tag.add_tag(server, tag_path, tag_info)
```
## Need More Information
**Visit:**
- [Kepconfig Package Documentation on Github Pages](https://ptcinc.github.io/Kepware-ConfigAPI-SDK-Python)
- [Kepware.com](https://www.kepware.com/)
- [PTC.com](https://www.ptc.com/)
Raw data
{
"_id": null,
"home_page": "https://github.com/PTCInc/Kepware-ConfigAPI-SDK-Python",
"name": "kepconfig",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Kepware, OPC, Configuration, Thingworx",
"author": "PTC Inc",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/f9/71/97ebc820fce25c6893f2d5bc9f1b1874e0b30983539c893c9dc82edd1a34/kepconfig-1.3.0.tar.gz",
"platform": null,
"description": "# Kepware Configuration API SDK for Python\r\n\r\n[![Released Version](https://img.shields.io/pypi/v/kepconfig)](https://pypi.org/project/kepconfig) [![Supported Versions](https://img.shields.io/pypi/pyversions/kepconfig)](https://pypi.org/project/kepconfig) ![PyPI - Downloads](https://img.shields.io/pypi/dm/kepconfig) ![PyPI - License](https://img.shields.io/pypi/l/kepconfig)\r\n\r\nThis is a package to help create Python applications to conduct operations with the Kepware Configuration API. This package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP). For reference, Kepware Server in this documentation will refer to both TKS and KEP versions.\r\n\r\n**API reference documentation is available on [Github Pages](https://ptcinc.github.io/Kepware-ConfigAPI-SDK-Python)**\r\n\r\n## Prerequisites\r\n\r\nPackage supported and tested on Python 3.9 or later. Older versions support earlier Python 3 environments but have less functionality. All HTTP communication is handled by the [urllib](https://docs.python.org/3/library/urllib.html#module-urllib) Python standard library.\r\n\r\n## Features\r\n\r\n- Supports both HTTP and HTTPS connections with certificate validation options\r\n\r\nPackage allows for *GET*, *ADD*, *DELETE*, and *MODIFY* functions for the following Kepware configuration objects:\r\n\r\n| Features | TKS/KEP | TKE |\r\n| :----------: | :----------: | :----------: |\r\n| **Project Properties** <br /> *(Get and Modify Only)* | Y | Y |\r\n| **Connectivity** <br /> *(Channel, Devices, Tags, Tag Groups)* | Y | Y |\r\n| **IoT Gateway** <br /> *(Agents, IoT Items)* | Y | Y |\r\n| **Datalogger** <br /> *(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)* | Y | Y |\r\n| **UA Gateway** <br /> *(Certificates, Server Endpoints, Client Connections, Server Interface parameters)* | Y*** | N |\r\n| **Administration** <br /> *(User Groups, Users, UA Endpoints, Local License Server)* | Y* | Y |\r\n| **Product Info and Health Status\\*\\*** | Y | Y |\r\n| **Import Project (via JsonProjectLoad Service) / Export Project\\*\\*\\*\\***| Y | Y |\r\n\r\n- Note (*) - UA Endpoints and Local License Server supported for Kepware Edge only\r\n- Note (**) - Added to Kepware Server v6.13 / Kepware Edge v1.5 and later builds\r\n- Note (***) - TKS only v6.16 and later\r\n- Note (****) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds\r\n\r\nDriver specific features:\r\n\r\n| Driver | Features |\r\n| :----------: | :----------: |\r\n|GE Ethernet Global Data|Exchanges, Ranges and Name Resolutions|\r\n|Universal Device Driver|Profile Library|\r\n\r\nMethods to read the following logs:\r\n\r\n| Logs | TKS/KEP | TKE |\r\n| :----------: | :----------: | :----------: |\r\n| **Event Log** | Y | Y |\r\n| **API Transaction Log** | Y | Y |\r\n\r\nConfiguration API *Services* implemented:\r\n\r\n| Services | TKS/KEP | TKE |\r\n| :----------: | :----------: | :----------: |\r\n| **TagGeneration** <br /> *(for supported drivers)* | Y | Y |\r\n| **ReinitializeRuntime** | Y* | Y |\r\n| **ProjectLoad and ProjectSave**| Y | Y |\r\n| **JsonProjectLoad\\*\\*** <br /> *(used for import project feature)*| Y | Y |\r\n\r\nNote (*) - Reinitialize service was implemented for Kepware Server v6.8+\r\n\r\nNote (**) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds\r\n\r\nFiltering, sorting and pagination query options are added for any collections methods (ex: `get_all_devices()` or `get_all_channel()`).\r\n\r\nGeneric REST methods are provided to use for functions not developed in SDK package. These are found in the `Server` class in [connection.py](./kepconfig/connection.py)\r\n\r\n## Known Limitations\r\n\r\n- Other property configuration for more complex drivers with objects besides channels, devices, tags and tag groups are not always explicitly defined\r\n- Other supported plug-ins (EFM Exporter, Scheduler, etc) are not defined\r\n- When using hostnames (not IP addresses) for connections, delays may occur under certain network configurations as the connection may attempt IPv6 connections first. IPv6 is not supported by Kepware servers at this time.\r\n\r\n## Installation\r\n\r\nPackage can be installed with `pip` using the following:\r\n\r\n```cmd\r\n pip install kepconfig\r\n```\r\n\r\n## Key Concepts\r\n\r\n**NOTE:** Detailed examples can also be found in the [examples](./examples/) folder.\r\n\r\n### Create server connection instance\r\n\r\n```python\r\nfrom kepconfig import connection\r\n\r\nserver = connection.server(host = '127.0.0.1', port = 57412, user = 'Administrator', pw = '')\r\n\r\n# For HTTPS connections:\r\nserver = connection.server(host = '127.0.0.1', port = 57512, user = 'Administrator', pw = '', https=True)\r\n\r\n```\r\n\r\nFor certificate validation, the SDK uses the OS/systems trusted certificate store. The connection uses the `create_default_context()` function as part of urllib as described at the following links:\r\n\r\n- [ssl.create_default_context](https://docs.python.org/3/library/ssl.html#ssl.create_default_context)\r\n- [ssl.SSLContext.load_default_certs](https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_default_certs)\r\n- [set_default_verify_paths](https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_default_verify_paths)\r\n\r\nFor Windows OSes, the Kepware Server's instance certificate can be loaded into the hosts \"Trusted Root Certificate Authorities\" store.\r\n\r\n### Create an object\r\n\r\nObjects such as channels or devices can be created either singularly or with children included.\r\n\r\n### Ex: Add Single channel\r\n\r\n```python\r\nfrom kepconfig.connectivity import channel\r\n\r\nchannel_data = {\"common.ALLTYPES_NAME\": \"Channel1\",\"servermain.MULTIPLE_TYPES_DEVICE_DRIVER\": \"Simulator\"}\r\nresult = channel.add_channel(server,channel_data)\r\n```\r\n\r\n### Ex: Add Multiple tags\r\n\r\n```python\r\nfrom kepconfig.connectivity import tag\r\n\r\ntag_info = [\r\n {\r\n \"common.ALLTYPES_NAME\": \"Temp\",\r\n \"servermain.TAG_ADDRESS\": \"R0\"\r\n },\r\n {\r\n \"common.ALLTYPES_NAME\": \"Temp2\",\r\n \"servermain.TAG_ADDRESS\": \"R1\"\r\n }\r\n]\r\ntag_path = '{}.{}.{}'.format(ch_name, dev_name, tag_group_path)\r\nresult = tag.add_tag(server, tag_path, tag_info)\r\n\r\n```\r\n\r\n## Need More Information\r\n\r\n**Visit:**\r\n\r\n- [Kepconfig Package Documentation on Github Pages](https://ptcinc.github.io/Kepware-ConfigAPI-SDK-Python)\r\n- [Kepware.com](https://www.kepware.com/)\r\n- [PTC.com](https://www.ptc.com/)\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "SDK package for Kepware Configuration API",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/PTCInc/Kepware-ConfigAPI-SDK-Python"
},
"split_keywords": [
"kepware",
" opc",
" configuration",
" thingworx"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "68af36e33cc9d1fba0c47a376d05c79189b746ce8584cb4343272167d8fe8b69",
"md5": "473c0ff50b80215902782bce7a5d7613",
"sha256": "baafd4f5a0ced53697ba987b4c3dc269d148a8344de80957fa1e1dd65044e4b6"
},
"downloads": -1,
"filename": "kepconfig-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "473c0ff50b80215902782bce7a5d7613",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 59078,
"upload_time": "2024-12-02T16:03:17",
"upload_time_iso_8601": "2024-12-02T16:03:17.860960Z",
"url": "https://files.pythonhosted.org/packages/68/af/36e33cc9d1fba0c47a376d05c79189b746ce8584cb4343272167d8fe8b69/kepconfig-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f97197ebc820fce25c6893f2d5bc9f1b1874e0b30983539c893c9dc82edd1a34",
"md5": "c5bf10169488d12494b9f20a5e5926fa",
"sha256": "2ff52242773dc748eab0f33e0ba4163091b9c3a395e9efb315cbb27b7c561e61"
},
"downloads": -1,
"filename": "kepconfig-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "c5bf10169488d12494b9f20a5e5926fa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 32610,
"upload_time": "2024-12-02T16:03:18",
"upload_time_iso_8601": "2024-12-02T16:03:18.869549Z",
"url": "https://files.pythonhosted.org/packages/f9/71/97ebc820fce25c6893f2d5bc9f1b1874e0b30983539c893c9dc82edd1a34/kepconfig-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-02 16:03:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PTCInc",
"github_project": "Kepware-ConfigAPI-SDK-Python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "kepconfig"
}