Developer docs?
Leichesters opened this issue · 7 comments
I wanted to build a project using Nostr but cant find docs for it. Having specifications is good but how do I start? Do you have a beginner friendly tutorial or some documentation?
For example here are some questions I have:
- Where do I send the request?
- How should I send it? In JSON?
- Can I send it from everywhere? Even from my browser in the developer tools for example?
Thanks for your help
import json
import ssl
import time
from nostr.event import Event
from nostr.relay_manager import RelayManager
from nostr.message_type import ClientMessageType
from nostr.key import PrivateKey
relay_manager = RelayManager()
relay_manager.add_relay("wss://nostr-pub.wellorder.net")
relay_manager.add_relay("wss://relay.damus.io")
relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disables ssl certificate verification
time.sleep(1.25) # allow the connections to open
private_key = PrivateKey()
event = Event("Hello Nostr")
private_key.sign_event(event)
relay_manager.publish_event(event)
time.sleep(1) # allow the messages to send
relay_manager.close_connections()
- Yes, Nostr has some Javascript libraries avaliable
- Where do I send the request?
requests are sent to relays via WebSocket, so we refer to them as a WebSocket URL, i.e var relay = new WebSocket('wss://relay.com')
- How should I send it? In JSON?
a request is a stringified array, i.e. relay.send(JSON.stringify(['REQ','sub_id',{filter},{filter}]))
- Can I send it from everywhere? Even from my browser in the developer tools for example?
yes
This is a good place to start for building a web client:
https://github.com/nbd-wtf/nostr-tools
Otherwise a lot of resources can be found here:
https://github.com/aljazceru/awesome-nostr
Hey thanks for your help. I was wondering how do you tell other servers about your data? Do you have to send it to multiple servers or will they forward it for you? Also is there a Javascript / Dart library available?
Yes, send it to multiple servers.
To publish something, you write a post, sign it with your key and send it to multiple relays.
The original protocol description says relays don't talk to other relays, but I believe some relays do talk to each other now.
For libraries see https://github.com/aljazceru/awesome-nostr