forked from axiom-team/astroport
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
|
import asyncio
|
||
|
import json
|
||
|
import sys
|
||
|
from duniterpy.api.client import Client
|
||
|
|
||
|
ES_CORE_ENDPOINT = "ES_CORE_API g1.data.duniter.fr 443"
|
||
|
ES_USER_ENDPOINT = "ES_USER_API g1.data.duniter.fr 443"
|
||
|
|
||
|
async def main():
|
||
|
"""
|
||
|
Main code (synchronous requests)
|
||
|
"""
|
||
|
# Create Client from endpoint string in Duniter format
|
||
|
client = Client(ES_USER_ENDPOINT)
|
||
|
|
||
|
# Get entry
|
||
|
# pubkey = input("\nEnter a public key to get the user profile: ")
|
||
|
# pubkey = "DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech"
|
||
|
pubkey = sys.argv[1]
|
||
|
|
||
|
# Get the profil of a public key (direct REST GET request)
|
||
|
# print("\nGET user/profile/{0}/_source:".format(pubkey))
|
||
|
# response = await client.get('tx/history/{0}'.format(pubkey.strip(' \n')))
|
||
|
response = await client.get('user/profile/{0}/_source'.format(pubkey.strip(' \n')))
|
||
|
print(json.dumps(response))
|
||
|
|
||
|
# Close client aiohttp session
|
||
|
await client.close()
|
||
|
|
||
|
# Latest duniter-python-api is asynchronous and you have to use asyncio, an asyncio loop and a "as" on the data.
|
||
|
# ( https://docs.python.org/3/library/asyncio.html )
|
||
|
asyncio.get_event_loop().run_until_complete(main())
|