Hello,
Please have a look at pyhpeimc, a native Python library for iMC that you can use to easily create your own scripts to interact with iMC via API. I've done this successfully with my lab installations numerous times and it's quite easy - the functions themselves that you can use all provide an example of how to implement them, and while far from all API features are covered by the libraries, it should be easy enough to use the existing ones as a kind of template to create others for your own needs.
https://github.com/HPENetworking/PYHPEIMC
Here is an extract of the comments on get_all_devs function that explains how you could make use of that function:
"""Takes string input of IP address to issue RESTUL call to HP IMC\n
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:param network_address: str IPv4 Network Address
:param category: str or int corresponding to device category (0=router, 1=switches, see API docs for other examples)
:return: dictionary of device details
:rtype: dict
>>> from pyhpeimc.auth import *
>>> from pyhpeimc.plat.device import *
>>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin")
>>> dev_list = get_all_devs( auth.creds, auth.url, network_address= '10.11.')
>>> assert type(dev_list) is list
>>> assert 'sysName' in dev_list[0]
"""
Hope that helps!