diff --git a/README.rst b/README.rst index 326caad2fb5d6b2dff5d5f05ddbe344ae18e9699..fb2df88158c6fbe9c57e93575ef463684529d2e2 100644 --- a/README.rst +++ b/README.rst @@ -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` diff --git a/examples/request_data_elasticsearch.py b/examples/request_data_elasticsearch.py index ba4d195951b82995126030241880a696826e4561..a93c70a3568b518937d45563511deef419b5f899 100644 --- a/examples/request_data_elasticsearch.py +++ b/examples/request_data_elasticsearch.py @@ -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 )