API to fetch all the parameter from specific device as well as all the parameter from all available ONT device

Hello,

I am trying to build an GenieACS API where i can fetch all parameter ( which have values) from specific device as well as all the parameter (which have values) from all available online / offline ONT device.

I am fairly new with API trying to understand API notes in documentation section. I believe i need to use GET Endpoint to just read.

Any suggestion and advise on how to get started or direction towards solution will be really appreciated.

I looked into the forum and i found my request is somewhat similar this thread but i need API to get those parameter values. I am using Huwei ONT as well.

My issue is more like same. I am little struggling on it.

Thanks,

This isn’t really possible (that I’m aware of). You can query all the devices, or query for all devices that have a specific value; and you can project the data, but you can’t (to my knowledge) have it only return params that have a value.

Example, if you want return the serial number for all CPEs that are online you would use:

curl -k -i 'https://localhost:7557/devices?query=%7B%22_lastInform%22%3A%7B%22%24gt%22%3A%222023-04-04%2000%3A00%3A00%20%2B0000%22%7D%7D&projection=DeviceID.SerialNumber'

The API docs have a lot of examples in them too.

Blockquote

Preformatted textHello,

I reviewed your update as well as API documentation and i was able configure NBI service to correctly point to repositories. However, i am runnign into some issues while fetching records.

  1. http://localhost:7557/devices ( Not using https )
    This correctly displays all the records in JSON format in web.

  2. I am querying using serial number shown below to get projection of SSID ( just for example purpose)

“_SerialNumber”:“48575443A3E562A3”

The result should return :

InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID → HOME

  1. I tried following:

curl -i 'http://localhost:7557/devices?query=%7B%22_SerialNumber%22%3A%20%2248575443A3E562A3%22%7D&projection=InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID'

HTTP/1.1 200 OK
GenieACS-Version: 1.2.8+20211027200938
Content-Type: application/json
total: 0
Date: Sun, 09 Apr 2023 12:09:49 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

(Trying just to list out all the values for given serial number)
curl -i 'http://localhost:7557/devices?query=%7B%22_SerialNumber%22%3A%20%2248575443A3E562A3%22%7D'
HTTP/1.1 200 OK
genieacs-version: 1.2.8+20211027200938
content-type: application/json
total: 0
date: Sun, 09 Apr 2023 12:10:17 GMT
keep-alive: timeout=5
transfer-encoding: chunked
access-control-allow-origin: *
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, JSNLog-RequestId, activityId, applicationId, applicationUserId, channelId, senderId, sessionId
access-control-max-age: 3628800
access-control-allow-methods: GET, DELETE, OPTIONS, POST, PUT

( Using -X GET)
curl -i -X GET 'http://localhost:7557/devices?query=%7B%22_SerialNumber%22%3A%20%2248575443A3E562A3%22%7D&projection=InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID'
HTTP/1.1 200 OK
GenieACS-Version: 1.2.8+20211027200938
Content-Type: application/json
total: 0
Date: Sun, 09 Apr 2023 12:12:32 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

Based on the output provided, it appears that your API call was successful and the server returned a HTTP response with a 200 OK status code. The response also includes the GenieACS version number, content type, and other headers.

However, the “total: 0” in the response suggests that the query i specified did not return any matching devices. I hope i can get answer where i am doing wrong and check the query parameter. I want to see the output (Value) of the attributes.

I hope i am making sense.

Thanks,

I tried again to fetch the record using device ID and i am able to but i am having a requirement where i want to fetch using MAC address or serial number of device and none of my attempt are working for Serial number and MAC address.

curl -i
'http://localhost:7557/devices?query=%7B%22_SerialNumber%22%3A%20%2248575443A3E562A3%22%7D'

Here, trying to get MAC address using serial number:
curl -i 'http://localhost:7557/devices?query=%7B%22InternetGatewayDevice.DeviceInfo.SerialNumber%22%3A%20%2248575443A3E562A3%22%7D&projection=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.MACAddress'

MAC address is not part of the device id, so to query by MAC address you either have to reference the field directly, or use a vparam to abstract that way (see the example vparam for examples).

_SerialNumber is not a valid parameter name to query by. You need to use _deviceId.SerialNumber when querying the NBI. When using a provision script, you would use DeviceID.SerialNumber.

Thanka @akcoder.

I was able to get the values by referencing to the field directly.
I am contiuing with my testing and will post if i have any question.

@kpuri1606 Thanks in Advance

Can your explain once how we can use api i have huawei ONT to for test and How to install and configure STUN server for Genieacs to contact with ont.becasue when i changed wifi ot try to commit any change to device in Genieacs it says device is offline.i have used AWS cloud ubuntu 20.04 lts.So kindly suggest.i am from india can we talk over whatsapp too plz provide plz reply.

Necromancy is frowned upon. Please create your own thread instead of trying to hijack a random thread thats is only tangentially related to what you are trying to accomplish.