Sunday, 21 April, 2019 UTC


Summary

This is another simple python tutorial to access API.We will access Pulsway APi using Python3 and Flask Framework. You can monitor systems from any mobile devices. You can manage systems, control applications and display data in real time.
Pulseway is a Real-Time Remote Monitoring and Management Software,its free up to 5 system and more with a subscribed account.It provide support for RMM Software, Remote Desktop, PSA, Antivirus and Backup.They also offers a Cloud API in Java and .NET languages to facilitate application development.
How To Integrate Pulseway With Python
Pulseway provides API endpoints to to handle rest api operation. We need to install 'slumber' packages into our python apps and use any rest end point.Let’s create folder 'pulseway-example' for sample project and api.py file into this folder.

How To Install slumber HTTP Client Package in Python

We will use slumber package to handle HTTP request.You can install slumber and flask package using following command –
pip install slumber
pip install flask

Create HTTP Request Using Slumber

We will create HTTP request using slumber to handle get system information.We will add below code into api.py file.
from flask import Flask
from flask_restful import Resource, Api
from flask_cors import CORS
import slumber
 
app = Flask(__name__)
CORS(app) ## To allow direct AJAX calls
 
@app.route('/getSystems', methods=['GET'])
def home():
   try:        
    api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))

    result = api.systems("28440dda-f385-4ec8-a5c3-d1e6074113bb").get()
    return r.json()

   except Exception as e:
    print('Publish raised an exception.')
    print(e.strerror)   

 
if __name__ == '__main__':
   app.run(debug = True)
Basic Authentication requires an Authorization header with the username and API token in the username:password format encoded as Base64.
Then we will fire HTTP get call with system id to get system information.
The post How To Access Pulseway RESTful API Using Python Flask appeared first on Rest Api Example.