python-nostr icon indicating copy to clipboard operation
python-nostr copied to clipboard

How to Query Relays for Specific Event Id

Open steveboi123 opened this issue 2 years ago • 1 comments

If I have an event id, and I want to get the entire event data, how can I query the relays to get it?

steveboi123 avatar Feb 25 '23 23:02 steveboi123

I think you can write a filter like this to fetch the specific event id you have:

filters = Filters([Filter(event_ids=["YOUREVENTIDSTRING"])])

Once you receive your requested event with code like this for example:

while relay_manager.message_pool.has_events():
  event_msg = relay_manager.message_pool.get_event()
  print(event_msg.event.PARAMETER)  # for example event_msg.content

You can get the event data with the following parameters: event_msg.id event_msg.pubkey event_msg.created_at event_msg.kind event_msg.tags event_msg.content event_msg.sig

f321x avatar Mar 10 '23 19:03 f321x