[Python] How to use the uCoin Python API?

Hello,

I want to use the uCoin Python API, so I tried this:


But in the print(data), I get that:

< generator object get at 0x7f86483b24c8>

or that:

< ucoinpyapi.ucoinpy.api.bma.node.Summary object at 0x7f52685cfa90>

The print(endpointBMA.conn_handler().str()) , gets the correct endpoint , the initial one.

https://sbhosting.me/zerobin/?10f5b2038c6ffc13#X7CXUfwl6PgIkvVrhToU+FAJ0/MBzLudlGUNAoGamFI=

To the following URL , the node send the correct data.
http://sbhosting.me:8999/node/summary
I use the browser Midori because, Firefox redirects to https, the node can’t handle HTTPS with my uCoin installation.

Latest ucoin-python-api is asynchronous and you have to use asyncio, an asyncio loop and a yield from on the data.

You have to use asyncio ( https://docs.python.org/3/library/asyncio.html )

For example (pseucode) :

import asyncio
import ucoinpy

@asyncio.coroutine
def get_node(loop):
    endpoint = Endpoint( ... )
    data = yield from Summaryk(endpoint.conn_handler()).get()
    print(data)

loop = asyncio.get_event_loop()
loop.run_until_complete(get_node(loop))
1 Like

:slight_smile:
It works !
thanks !

https://sbhosting.me/zerobin/?fba415727d19ad4b#+H/+Gke4Inp+dgXTHCckklyp+icKpXDsGOVvu7iHUuw=

ReadTheDocs.org in progress :
http://ucoin-python-api.readthedocs.org/en/latest/

2 Likes

Ca ne me choque pas outre mesure personellement. Surtout que rien n’empeche le client d’être porté en tant qu’application sur un media center local par exemple :slight_smile:

1 Like

Un truc qui serait vraiment sympa, c’est un visualiseur du WoT, animé dans le temps.

Ya pas mal de librairies en JS pour faire ça : http://d3js.org/

Tu pourrais par exemple analyser le WoT par la requete sur les membres de la communauté puis des certifiers-of sur chaque pubkey, placer ça dans un graph via networkx ( http://networkx.github.io/ ) puis rendre tout ça dans le navigateur grace à d3js.
Sacré challenge je suppose mais qui aurait vraiment une valeur ajoutée dans le cadre de ucoin :wink: Le must serait d’afficher le WoT(t) !

1 Like

For developers who want to read JSON files / requests in the browser
I recommend to use a JSON viewer for a readable JSON
For example -> http://jsonview.com

; )

1 Like

Thanks for this documentation, I will read it with care.
I could also contribute to it as it’s old now.
Where could I found sources ?
We should a link to this tutorial on the readme of the repository duniter-python-api.