pythonrestmikrotik

Mikrotik: How can I get the data from /interface/lte/lte1/cellular via rest API


I build a script which uses the request.get to get data from a specific path of Mikrotik router (and it works), but I don't know the path for interface/lte/lte1/cellular (the cellular is the problem). How can I get the cellular data (rssi, rsrp, rsrq, sinr) via rest API? (You can get the data manually via winbox if you use that interface/lte/lte1/cellular)

I build this script:`

import json
import signal
import time
from datetime import datetime
import requests
import urllib3
from requests.auth import HTTPBasicAuth

urllib3.disable_warnings()

url = 'https://<myip>/rest'
userName = '<user>'
password = '<pw>'
path= ['/interface', '/ip/address']
#'/interface', '/ip/address' in path are just examples for what paths look like  

response = []

for elements in path:
        response.append({"path": elements, "response": requests.get(url + elements, auth=HTTPBasicAuth(userName, password), verify=False)})

        currTime = datetime.now().astimezone().strftime('%Y-%m-%dT%H:%M:%S.%f%z')

        for line in response:
            data = {
                'timeLoc': currTime, line["path"] :  json.loads(line["response"].text)
            }

        file.write(json.dumps(data))`

I tried the path='/interface/lte/lte1/cellular' --> didn't work!

I tried the path='/interface/lte/info' --> didn't work!

I tried the path='/interfae/lte/lte1' --> works but its not the data I want!


Solution

  • Use POST

    curl -k -u user:pass -X POST https://<ip-address>/rest/interface/lte/monitor -d '{"numbers":0, "duration":1}' -H "content-type: application/json"
    

    Reference in documentation