Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
c03343a1
Commit
c03343a1
authored
6 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
issue
#56
add ES_USER_API example
parent
2326b1d9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.rst
+1
-1
1 addition, 1 deletion
README.rst
examples/request_data_elasticsearch.py
+15
-0
15 additions, 0 deletions
examples/request_data_elasticsearch.py
with
16 additions
and
1 deletion
README.rst
+
1
−
1
View file @
c03343a1
...
...
@@ -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`
...
...
This diff is collapsed.
Click to expand it.
examples/request_data_elasticsearch.py
+
15
−
0
View file @
c03343a1
...
...
@@ -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
(
"
\n
Enter a public key to get the user profile:
"
)
# Get the profil of a public key (direct REST GET request)
print
(
"
\n
GET 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 )
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment