You can interact with the Nostr protocol through this REST API. Supports posting notes, reacting to notes, replying to notes, sending direct messages and reading notes based on filters or mentions.
A simple API to perform actions on the Nostr protocol.
To use the API you will need to send your nsec in hex format in the HTTP request header as X-Auth-NSEC
.
{ "status": "success", "action": "action_name", "notes": [ { "id": "note_id", "content": "Note content", "tags": [["p", "public_key"]], "created_at": 1695999999 } ] }
{ "status": "error", "message": "Invalid JSON input or missing 'action' field." }
{ "action": "postNote", "content": "Hello world!", "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = postNote | required | |
content | string | The content of the note. | optional | |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "reactToNote", "note_id": "cd9d5761f085d73b47d2968825750068cbd7bfb5e64805b97dfc820822fb438b", "reaction": "+", "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = reactToNote | required | |
note_id | string | The ID of the note to react to or reply to. | requird | |
reaction | string | The reaction (e.g., + , 👍 ). | optional | |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "replyToNote", "note_id": "cd9d5761f085d73b47d2968825750068cbd7bfb5e64805b97dfc820822fb438b", "reply_content": "This is a reply!", "author_pubkey": "pubkey_of_original_author", "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = replyToNote | required | |
note_id | string | The ID of the note to react to or reply to. | required | |
reply_content | string | The content of the reply. | required | |
author_pubkey | string | The public key of the author of the note being replied to. | optional | |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "sendDirectMessage", "recipient": "pubkey_of_the_recipient", "content": "This is a message", "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = sendDirectMessage | required | |
recipient | string | The public key of the recipient of the message. | required | |
content | string | The content of the note. | required | |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "readDirectMessage", "limit": 5, "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = readDirectMessage | required | |
limit | integer | The maximum number of results to return. | optional | 20 |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "readNotesByFilter", "filter": { "kinds": [1], "authors": ["author_public_key_hex"], "tags": [ {"t": "test"} ] }, "limit": 10, "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = readNotesByFilter | required | |
filter | object | Filter by kinds, authors and/or tags. Tags are evaluated as OR. | optional | |
limit | integer | The maximum number of results to return. | optional | 20 |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "readNotesMentioningMe", "limit": 5, "relay_url": "wss://relay.damus.io" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = readNotesMentioningMe | required | |
limit | integer | The maximum number of results to return. | optional | 20 |
relay_url | string | The WebSocket URL of the relay. | optional | wss://relay.damus.io |
{ "action": "convertKey", "nsec_hex": "nsec_hex", "nsec_bech32": "nsec_bech32", "npub_hex": "npub_hex", "npub_bech32": "npub_bech32" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = convertKey | required | |
nsec_hex | string | The nsec in hex format to be converted. | optional | |
nsec_bech32 | string | The nsec in bech32 format to be converted. | optional | |
npub_hex | string | The npub in hex format to be converted. | optional | |
npub_bech32 | string | The npub in bech32 format to be converted. | optional |
{ "action": "encryptContent", "recipient": "pubkey_of_the_recipient", "content": "This is a message" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = encryptContent | required | |
recipient | string | The public key of the recipient of the message. | required | |
content | string | The content to be encrypted. | required |
{ "action": "decryptContent", "sender": "pubkey_of_the_sender", "encrypted_content": "LJxTnKadoSp+fBjIobgK85hA04jVmAg9PRiTMaPOoS4=?iv=kvompmANGDiCChSvY1w0Qg==" }
Field | Type | Description | Required? | Default |
---|---|---|---|---|
action | string | The action to perform = decryptContent | required | |
sender | string | The public key of the sender of the message. | required | |
encrypted_content | string | The encrypted content to be decrypted. | required |