在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:semolex/nis-python-client开源软件地址:https://github.com/semolex/nis-python-client开源编程语言:Python 100.0%开源软件介绍:python-nis-clientPython client for NEM NIS API. PrerequisitesInstall all required dependencies into your
DescriptionClient implements methods from NEM API by calling appropriate method.
Method names are consist of API parent parts and related resources (where hyphens and slashes replaced with underscore).
Its mean, that following API resource - Almost all methods are implemented this way, except few that has either super-long names or duplicate names. Simply discover all methods to see exact namings. There is 6 API parent resource entities for usage:
Extended code guide for available classes can be found here. Few call can be used directly from UsageExamples of usage: from nemnis import Client, explain_status
nis = Client()
hb = nis.heartbeat()
status = nis.status()
print(status.json())
# you can use following function to get verbose message for status
print(explain_status(status.json()))
print(hb.status_code)
print(hb.json())
acc = nis.account.get('NCKMNCU3STBWBR7E3XD2LR7WSIXF5IVJIDBHBZQT')
print(acc.status_code)
print(acc.json())
### You can connect to other nodes just by passing it address:
new_client = Client('http://157.7.223.222:7890')
new_hb = new_client.heartbeat()
print(new_hb.status_code)
print(new_hb.json()) All responses are You also can perform call via from nemnis import Client
nis = Client()
nis.call('GET', 'heartbeat')
nis.call('GET', 'account/get', params={'address':'SOMEADDRESS'})
nis.call('POST', 'local/chain/blocks-after', payload={'height': 100}) Also, each parent resource can be initialized separately by passing client instance as parameter: from nemnis import Client, Node
nis = Client()
node = Node(nis)
node_info = node.info()
print(node_info.status_code)
print(node_info.json()) Asynchronous UsageOn Python 3.4.2 and above, the python-nis-client supports asynchronous requests using the Three helper functions are also provided for the asynchronous API:
- Examples of usage: import nemnis
# get our client
nis = nemnis.AsyncioClient()
# request a single NIS resource
hb = nis.run(nis.heartbeat())
print(nis.run(hb.json()))
# request many NIS resources asynchronously
hb = nis.heartbeat()
status = nis.status()
responses = nemnis.map([hb, status])
print(nis.map([i.json() for i in responses])) Special thanks to Alex Huszagh for contributing async client part. Have fun! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论