All Projects → semolex → nis-python-client

semolex / nis-python-client

Licence: MIT license
Python client for NEM NIS API (https://nemproject.github.io). XEM\NEM\Crypto

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to nis-python-client

pacNEM
pacNEM is a Browser PacMan game with NodeJS, Socket.io, Handlebars and NEM Blockchain
Stars: ✭ 20 (+25%)
Mutual labels:  nem, blockchain-technology, nem-blockchain
symbol-faucet
Faucet application for symbol
Stars: ✭ 12 (-25%)
Mutual labels:  nem, nem-blockchain
symbol-dojo
nem2(catapult) Learning Hands-on Project (道場)
Stars: ✭ 12 (-25%)
Mutual labels:  nem, nem-blockchain
rippled-php
A PHP library for rippled (XRP Ledger) communication.
Stars: ✭ 33 (+106.25%)
Mutual labels:  api-client, blockchain-technology
yelp-ios
No description or website provided.
Stars: ✭ 61 (+281.25%)
Mutual labels:  api-client
golio
League of Legends API client written in Golang
Stars: ✭ 45 (+181.25%)
Mutual labels:  api-client
rdfp
This R package connects the DoubleClick for Publishers API from R
Stars: ✭ 16 (+0%)
Mutual labels:  api-client
binance-client-websocket
🛠️ C# client for Binance websocket API
Stars: ✭ 41 (+156.25%)
Mutual labels:  api-client
tempo-api-python-client
Python bindings for Tempo - https://apidocs.tempo.io/
Stars: ✭ 17 (+6.25%)
Mutual labels:  api-client
DummyJSON
DummyJSON provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
Stars: ✭ 213 (+1231.25%)
Mutual labels:  api-client
sia-cog
Various cognitive api for machine learning, vision, language intent alalysis. Covers traditional as well as deep learning model design and training.
Stars: ✭ 34 (+112.5%)
Mutual labels:  api-client
frontend
Cambiatus Web based frontend using Elm
Stars: ✭ 25 (+56.25%)
Mutual labels:  currency
php-abraflexi
PHP Based Library for easy interaction with czech accounting system FlexiBee.
Stars: ✭ 15 (-6.25%)
Mutual labels:  api-client
YuiAPI
一个浏览器API测试客户端,API文档生成器,支持chrome/firefox/新版edge
Stars: ✭ 25 (+56.25%)
Mutual labels:  api-client
qvapay-python
Non official, but friendly QvaPay library for the Python language.
Stars: ✭ 18 (+12.5%)
Mutual labels:  api-client
drowsy
😪 Lazy integrations tool for RESTful interfaces to aid POC development and streamline integrations
Stars: ✭ 19 (+18.75%)
Mutual labels:  api-client
fingernft
FingerNFT是一款开源NFT市场,兼容Opensea、Rarible。
Stars: ✭ 1,827 (+11318.75%)
Mutual labels:  blockchain-technology
strava
PHP Class for the Strava API (v3)
Stars: ✭ 117 (+631.25%)
Mutual labels:  api-client
noire-server
Hapi Boilerplate
Stars: ✭ 20 (+25%)
Mutual labels:  api-client
Simple-Game-ERC-721-Token-Template
🔮 Very Simple ERC-721 Smart Contract Template to create your own ERC-721 Tokens on the Ethereum Blockchain, with many customizable Options 🔮
Stars: ✭ 83 (+418.75%)
Mutual labels:  blockchain-technology

python-nis-client

Python client for NEM NIS API.

Prerequisites

Install all required dependencies into your virtualenv (if you want to use it):

pip install git+https://github.com/semolex/nis-python-client

Description

Client 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 - namespace/root/page is implemented as client.namespace.root_page and node/info is client.node.info, etc.

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:

  • Account
  • BlockChain
  • Node
  • Namespace
  • Transaction
  • Debug

Extended code guide for available classes can be found here.

Few call can be used directly from Client instance. To perform calls to the NEM NIS API, ensure you have access to running NIS instance. By default NIS uses 7890 port, you can initialize NIS client with other address.

Usage

Examples 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 requests.Response objects from requests library. You can perform all required manipulations after receiving them: convert to JSON, check status code etc.

You also can perform call via call method from Client:

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 Usage

On Python 3.4.2 and above, the python-nis-client supports asynchronous requests using the aiohttp library. Each method returns an asyncio coroutine returning a response object; otherwise, the API is identical to the standard client.

Three helper functions are also provided for the asynchronous API: - loop() Returns the asyncio event loop. - run(future) Evaluate a single asyncio coroutine or future. - map(futures) Evaluate a sequence of asyncio coroutines or futures.

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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].