import json, requests
payload = {"method": "read", "params": ["TAG1", "TAG2"]}
response = requests.get("http://IP:PORT/", payload, timeout=1)
values = json.loads(response.content)
# print TAG1 and TAG2
print(values(0)(1))
print(values(1)(1))
Python Rest API using OpenOPC to provide direct API access for any OS platform. This proxy has to be installed on a Windows box with Python and OpenOPC installed to provide a API Gateway to other platforms.
This code is dependent on https://sourceforge.net/projects/openopc/files/ by Barry Barnreiter and Python 2.7
On your Windows server, install OpenOpc. Make sure that OpenOPC connects properly to your OPC Server. Documentation for OpenOPC on http://openopc.sourceforge.net/. Once OpenOPC is connected, download http2opc code above and drop it in your preferred diretory.
Run python main.py from the http2opc directory to start the API Daemon. Function documentation on http://headstation.com/archives/using-opc-rest-api/
Copyright 2016 Headstation. (http://headstation.com) All rights reserved. It is free software and may be redistributed under the terms specified in the LICENSE file (Apache License 2.0).