Jump to content
  • 0

get mobile data usage through restapi


Question

1 answer to this question

Recommended Posts

  • 0
Posted
On 1/28/2025 at 10:31 AM, AliasNameless said:

Hi all, I need to get mobile data usage through rest api (for my openhab server). There are two ways to get the limits. Router's counter and  ussd command. The second way is more preferable, because the provider's data is slightly different from the router's counter.

Is there any way to log this data touch restapi?

Yes, it is possible. To send a USSD request via REST API, you need to perform the following actions:

1. send a POST request to <keenetic_ip_or_domain>/rci/ussd/send with a JSON body specifying the interface and the request, for example:

{
  "interface": "UsbLte0",
  "request": "*100#"
}

2. you will get a JSON response object
    if it contains “continued”: true, you need to send a GET request to the same endpoint (<keenetic_ip_or_domain>/rci/ussd/send)

    if not, you should receive either JSON containing the response to your USSD request or JSON with an error message
    

3. if the GET request response contains “continued”: true, repeat this action again (it makes sense to wait before sending the next request, e.g. 1 second)
    if not, you should receive either JSON containing the response to your USSD request or JSON with an error message

 

A few extra notes:

- you need to be authorized on the Keenetic to send the requests;
   the auth process is described here (in Russian): https://forum.keenetic.ru/topic/5461-не-работает-digest-авторизация-для-rci/#findComment-62946
   preserve session cookies while sending follow-up GET requests

- don't forget to set the Content-Type HTTP header for your requests (Content-Type: application/json)

- you can see how the web UI handles USSD requests using WebCLI:

 

  • Upvote 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...