Commit c03343a1 authored by Vincent Texier's avatar Vincent Texier

issue #56 add ES_USER_API example

parent 2326b1d9
......@@ -41,7 +41,7 @@ Please take a look at the document `HTTP API <https://git.duniter.org/nodes/type
Development
-----------
* Create a python environment with `pyenv <https://github.com/pyenv/pyenv>`_ ::
* Create a python virtual environment with `pyenv <https://github.com/pyenv/pyenv>`_ ::
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash`
......
......@@ -11,6 +11,7 @@ from duniterpy.api.client import Client
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the secure BASIC_MERKLED_API (BMAS)
ES_CORE_ENDPOINT = "ES_CORE_API g1-test.data.duniter.fr 443"
ES_USER_ENDPOINT = "ES_USER_API g1-test.data.duniter.fr 443"
################################################
......@@ -36,6 +37,20 @@ async def main():
# Close client aiohttp session
await client.close()
# Create Client from endpoint string in Duniter format
client = Client(ES_USER_ENDPOINT)
# prompt entry
pubkey = input("\nEnter a public key to get the user profile: ")
# Get the profil of a public key (direct REST GET request)
print("\nGET user/profile/{0}/_source:".format(pubkey))
response = await client.get('user/profile/{0}/_source'.format(pubkey.strip(' \n')))
print(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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment