API Reference

The Nostr Gateway REST API lets you publish and query Nostr events via simple HTTP calls โ€” no WebSockets, no NIPs, no Schnorr signatures required.

Quick Start

Get your first Nostr post published in under 2 minutes:

1. Create a free account

# Register โ€” returns your API key
curl -X POST https://gateway.agilesolutionlabs.com/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com"}'

2. Publish your first post

curl -X POST https://gateway.agilesolutionlabs.com/v1/posts \
  -H "Authorization: Bearer nk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"Hello Nostr! Posted via Nostr Gateway ๐Ÿš€"}'

3. Query your posts

curl "https://gateway.agilesolutionlabs.com/v1/events?kinds=1&limit=5" \
  -H "Authorization: Bearer nk_live_YOUR_API_KEY"
Your account comes with a managed Nostr keypair โ€” no key management needed. See BYOK Mode if you want to use your own private key.

Authentication

All endpoints (except POST /v1/auth/register) require a Bearer token in the Authorization header:

Authorization: Bearer nk_live_YOUR_API_KEY

API keys are prefixed with nk_live_ and are generated at registration. You can create additional keys or rotate existing ones from the dashboard.

Store your API key securely โ€” it is shown only once. If lost, rotate it from the dashboard to get a new one.

Base URL

https://gateway.agilesolutionlabs.com

All endpoints are versioned under /v1/. Responses are JSON.

Errors

Error responses follow this shape:

{
  "error": "Human-readable message"
}
StatusMeaning
400Bad request โ€” missing or invalid fields
401Unauthorized โ€” missing or invalid API key
403Forbidden โ€” email not verified, or action not allowed
404Not found
409Conflict โ€” e.g. email already registered
429Rate limit exceeded
500Internal server error

Rate Limits

Rate limits are enforced per API key using a tumbling window.

TierRequests/minRequests/dayRelays/publishAPI Keys
Free101,00032
Pro6050,0001010
Enterprise300500,0005050

When exceeded, the API returns 429 Too Many Requests.

Register

POST /v1/auth/register

Create a new account. Returns your first API key and your managed Nostr pubkey. A verification email is sent automatically.

Request body

FieldTypeDescription
emailrequiredstringYour email address

Response

{
  "user_id": "uuid",
  "api_key": "nk_live_...",
  "api_key_id": "uuid",
  "pubkey": "hex pubkey",
  "npub": "npub1...",
  "message": "Account created. Check your email to verify."
}
Save the api_key โ€” it is shown only once and cannot be recovered.

Create API Key

POST /v1/auth/keys

Create an additional API key. Free tier allows 2 keys, Pro allows 10.

Request body

FieldTypeDescription
nameoptionalstringLabel for this key (e.g. "production")
keypair_modeoptionalstringmanaged (default) or byok
relay_urlsoptionalstring[]Default relay list for this key

Response

{
  "api_key": "nk_live_...",
  "api_key_id": "uuid",
  "pubkey": "hex pubkey"
}

List API Keys

GET /v1/auth/keys

Returns all active API keys for your account.

Response

{
  "keys": [
    {
      "id": "uuid",
      "name": "default",
      "tier": "free",
      "keypair_mode": "managed",
      "managed_pubkey": "hex pubkey",
      "is_active": true,
      "last_used_at": 1712345678,
      "created_at": 1712300000
    }
  ]
}

Revoke API Key

DELETE /v1/auth/keys/:id

Permanently revokes an API key. You cannot revoke your last active key.

Response

{ "ok": true }

Rotate API Key

POST /v1/auth/keys/:id/rotate

Invalidates the current key secret and issues a new one with the same ID and settings.

Response

{
  "api_key": "nk_live_...",
  "api_key_id": "uuid"
}

Get Keypair

GET /v1/keypair

Returns the managed Nostr public key associated with this API key.

Response

{
  "pubkey": "abc123...",
  "npub": "npub1..."
}

Create Post

POST /v1/posts

Publishes a kind-1 text note (the most common Nostr event type).

Request body

FieldTypeDescription
contentrequiredstringThe text content of the note
tagsoptionalarray[][]Nostr tags (e.g. [["t","bitcoin"]])
relay_urlsoptionalstring[]Override default relays for this request

Example

curl -X POST https://gateway.agilesolutionlabs.com/v1/posts \
  -H "Authorization: Bearer nk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hello from Nostr Gateway!",
    "tags": [["t", "nostr"], ["t", "bitcoin"]]
  }'

Response

{
  "event_id": "hex event id",
  "pubkey": "hex pubkey",
  "relay_results": [
    { "relay": "wss://relay.example.com", "ok": true }
  ]
}

Update Profile

POST /v1/profiles

Publishes a kind-0 metadata event (profile update).

Request body

FieldTypeDescription
nameoptionalstringDisplay name
aboutoptionalstringBio / description
pictureoptionalstringAvatar URL
websiteoptionalstringWebsite URL
nip05optionalstringNIP-05 identifier (e.g. user@domain.com)
relay_urlsoptionalstring[]Override default relays

Example

curl -X POST https://gateway.agilesolutionlabs.com/v1/profiles \
  -H "Authorization: Bearer nk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Alice",
    "about": "Building on Nostr",
    "picture": "https://example.com/avatar.png"
  }'

React to Event

POST /v1/reactions

Publishes a kind-7 reaction (like/dislike) to another event.

Request body

FieldTypeDescription
event_idrequiredstringHex ID of the event to react to
pubkeyrequiredstringPubkey of the event author
contentoptionalstring+ (like, default), - (dislike), or an emoji
relay_urlsoptionalstring[]Override default relays

Repost

POST /v1/reposts

Publishes a kind-6 repost of another event.

Request body

FieldTypeDescription
event_idrequiredstringHex ID of the event to repost
pubkeyrequiredstringPubkey of the original author
relay_urlsoptionalstring[]Override default relays

Send DM

POST /v1/dms

Publishes a kind-4 encrypted direct message (NIP-04).

Request body

FieldTypeDescription
recipient_pubkeyrequiredstringHex pubkey of the recipient
contentrequiredstringPlaintext message โ€” encrypted automatically
relay_urlsoptionalstring[]Override default relays
Content is encrypted using NIP-04 (AES-256-CBC + ECDH) before publishing. You send plaintext, we handle the crypto.

Update Follow List

POST /v1/follows

Publishes a kind-3 contact list (follow list). Replaces the existing follow list.

Request body

FieldTypeDescription
followsrequiredstring[]Array of hex pubkeys to follow
relay_urlsoptionalstring[]Override default relays

Example

{
  "follows": [
    "abc123...",
    "def456..."
  ]
}

Publish Raw Event

POST /v1/events

Publish any Nostr event kind. The event is signed automatically with your managed keypair (or your BYOK key).

Request body

FieldTypeDescription
kindrequiredintegerNostr event kind number
contentrequiredstringEvent content
tagsoptionalarray[][]Nostr tags array
relay_urlsoptionalstring[]Override default relays

Example โ€” publish a long-form article (kind 30023)

{
  "kind": 30023,
  "content": "# My Article\n\nLong form content here...",
  "tags": [
    ["title", "My Article"],
    ["d", "my-article-slug"]
  ]
}

Query Events

GET /v1/events

Query events from the relay using NIP-01 filter parameters.

Query parameters

ParamTypeDescription
kindsoptionalstringComma-separated kind numbers (e.g. 1,6,7)
authorsoptionalstringComma-separated hex pubkeys
sinceoptionalintegerUnix timestamp โ€” events after this time
untiloptionalintegerUnix timestamp โ€” events before this time
limitoptionalintegerMax results (default 20, max 100)
relay_urloptionalstringRelay to query (overrides default)

Example

curl "https://gateway.agilesolutionlabs.com/v1/events?kinds=1&limit=10" \
  -H "Authorization: Bearer nk_live_..."

Response

{
  "events": [
    {
      "id": "hex event id",
      "pubkey": "hex pubkey",
      "kind": 1,
      "content": "Hello Nostr!",
      "created_at": 1712345678,
      "tags": [],
      "sig": "hex signature"
    }
  ]
}

Get Event

GET /v1/events/:id

Fetch a single event by its hex ID.

Example

curl https://gateway.agilesolutionlabs.com/v1/events/abc123... \
  -H "Authorization: Bearer nk_live_..."

Get Profile

GET /v1/profiles/:pubkey

Fetch a Nostr profile (kind-0 metadata) by hex pubkey.

Response

{
  "pubkey": "hex pubkey",
  "name": "Alice",
  "about": "Building on Nostr",
  "picture": "https://...",
  "nip05": "alice@example.com"
}

BYOK Mode โ€” Bring Your Own Key

By default, Nostr Gateway manages a keypair for you. To sign events with your own Nostr private key, add the X-Nostr-Privkey header:

curl -X POST https://gateway.agilesolutionlabs.com/v1/posts \
  -H "Authorization: Bearer nk_live_..." \
  -H "X-Nostr-Privkey: YOUR_64_CHAR_HEX_PRIVKEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"Signed with my own key!"}'
Your private key is used only to sign the event in-memory and is never stored. Use HTTPS only โ€” the key is transmitted in a header.

Multi-Relay Publishing

By default, events are published to wss://relay.agilesolutionlabs.com. You can publish to multiple relays in a single request by passing relay_urls:

{
  "content": "Broadcast to multiple relays!",
  "relay_urls": [
    "wss://relay.agilesolutionlabs.com",
    "wss://relay.damus.io",
    "wss://nos.lol"
  ]
}

The response includes per-relay results so you know which relays accepted or rejected the event.

The number of relays you can target per request depends on your tier โ€” Free: 3, Pro: 10, Enterprise: 50.

Usage Stats

GET /v1/usage

Returns request counts and per-endpoint breakdown for the current API key.

Query parameters

ParamTypeDescription
periodoptionalstringtoday (default), 7d, or 30d

Response

{
  "period": "today",
  "total_requests": 142,
  "successful_requests": 138,
  "failed_requests": 4,
  "by_endpoint": [
    { "endpoint": "/v1/posts", "cnt": 80 },
    { "endpoint": "/v1/events", "cnt": 62 }
  ],
  "rate_limit": {
    "rpm_limit": 10,
    "rpd_limit": 1000
  }
}