SCADA-LTS / Scada-LTS

Scada-LTS is an Open Source, web-based, multi-platform solution for building your own SCADA (Supervisory Control and Data Acquisition) system.
GNU General Public License v2.0
744 stars 292 forks source link

Python API #1837

Closed JoseVinicius1998 closed 3 years ago

JoseVinicius1998 commented 3 years ago

Hello guys. Scada-LTS allows API with Python 3? Someone can help me? What module is more easy to use (suds, soappy, others)? Someone has an example of how to do? Thanks for the attention!

Sorry my english, i'm brazilian

radek2s commented 3 years ago

Hello @JoseVinicius1998 We are not sure what do you mean with "Scada-LTS allows API with Python 3". We have prepared Java REST API that allows user to request the application from any tool that supports HTTP Requests. We use in our purpose JavaScript for our interface but you can also use Python scripts to receive data from Scada-LTS. All supported methods are listed in our API documentation file. But if you want just to send a request for a data from Scada-LTS from your own Python script find the solutions on the Web how to use python request library. Example is provided here:

import requests

url = 'http://localhost:8080/ScadaBR/api/point_value/getValue/{xid}'

x = requests.get(url)

print(x.text)
JoseVinicius1998 commented 3 years ago

I always get stuck because the code asks for authentication, both on soap and on Rest. But I believe it can be solved. Thanks!

radek2s commented 3 years ago

Ok so try to login using API:

http://localhost:8080/ScadaBR/api/auth/<<username>>/<<password>>

Just send that one request on the beginning, before you send request for data.

JoseVinicius1998 commented 3 years ago

Thanks Man!!! I did it! I am very grateful, the API is working perfectly! It's a big resource. I leave the code I used:

############################################################## import requests

session = requests.Session() url = 'http://localhost:8080/ScadaBR/api/auth/admin/admin' x = session.get(url) print(x.text) url = 'http://localhost:8080/ScadaBR/api/point_value/getValue/DP_722633' y = session.get(url) print(y.text) ##############################################################