Rewrite, edit and organize examples/rest demos.

This commit is contained in:
Davide Casale
2023-02-20 18:11:10 +01:00
parent e3eb3d6a56
commit cec9d6ba68
33 changed files with 353 additions and 589 deletions

View File

@@ -0,0 +1,24 @@
# python -c "import examples.rest.public.pulse_endpoints"
import datetime
from bfxapi import Client, PUB_REST_HOST
from bfxapi.rest.types import List, PulseMessage, PulseProfile
bfx = Client(REST_HOST=PUB_REST_HOST)
# POSIX timestamp in milliseconds (check https://currentmillis.com/)
end = datetime.datetime(2020, 5, 2).timestamp() * 1000
# Retrieves 25 pulse messages up to 2020/05/02
messages: List[PulseMessage] = bfx.rest.public.get_pulse_history(end=end, limit=25)
for message in messages:
print(f"Message author: {message.profile.nickname} ({message.profile.puid})")
print(f"Title: <{message.title}>")
print(f"Tags: {message.tags}\n")
profile: PulseProfile = bfx.rest.public.get_pulse_profile("News")
URL = profile.picture.replace("size", "small")
print(f"<{profile.nickname}>'s profile picture: https://s3-eu-west-1.amazonaws.com/bfx-pub/{URL}")