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"
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.
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"
}
| Status | Meaning |
|---|---|
| 400 | Bad request โ missing or invalid fields |
| 401 | Unauthorized โ missing or invalid API key |
| 403 | Forbidden โ email not verified, or action not allowed |
| 404 | Not found |
| 409 | Conflict โ e.g. email already registered |
| 429 | Rate limit exceeded |
| 500 | Internal server error |
Rate Limits
Rate limits are enforced per API key using a tumbling window.
| Tier | Requests/min | Requests/day | Relays/publish | API Keys |
|---|---|---|---|---|
| Free | 10 | 1,000 | 3 | 2 |
| Pro | 60 | 50,000 | 10 | 10 |
| Enterprise | 300 | 500,000 | 50 | 50 |
When exceeded, the API returns 429 Too Many Requests.
Register
Create a new account. Returns your first API key and your managed Nostr pubkey. A verification email is sent automatically.
Request body
| Field | Type | Description |
|---|---|---|
| emailrequired | string | Your 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."
}
api_key โ it is shown only once and cannot be recovered.Create API Key
Create an additional API key. Free tier allows 2 keys, Pro allows 10.
Request body
| Field | Type | Description |
|---|---|---|
| nameoptional | string | Label for this key (e.g. "production") |
| keypair_modeoptional | string | managed (default) or byok |
| relay_urlsoptional | string[] | Default relay list for this key |
Response
{
"api_key": "nk_live_...",
"api_key_id": "uuid",
"pubkey": "hex pubkey"
}
List API 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
Permanently revokes an API key. You cannot revoke your last active key.
Response
{ "ok": true }
Rotate API Key
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
Returns the managed Nostr public key associated with this API key.
Response
{
"pubkey": "abc123...",
"npub": "npub1..."
}
Create Post
Publishes a kind-1 text note (the most common Nostr event type).
Request body
| Field | Type | Description |
|---|---|---|
| contentrequired | string | The text content of the note |
| tagsoptional | array[][] | Nostr tags (e.g. [["t","bitcoin"]]) |
| relay_urlsoptional | string[] | 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
Publishes a kind-0 metadata event (profile update).
Request body
| Field | Type | Description |
|---|---|---|
| nameoptional | string | Display name |
| aboutoptional | string | Bio / description |
| pictureoptional | string | Avatar URL |
| websiteoptional | string | Website URL |
| nip05optional | string | NIP-05 identifier (e.g. user@domain.com) |
| relay_urlsoptional | string[] | 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
Publishes a kind-7 reaction (like/dislike) to another event.
Request body
| Field | Type | Description |
|---|---|---|
| event_idrequired | string | Hex ID of the event to react to |
| pubkeyrequired | string | Pubkey of the event author |
| contentoptional | string | + (like, default), - (dislike), or an emoji |
| relay_urlsoptional | string[] | Override default relays |
Repost
Publishes a kind-6 repost of another event.
Request body
| Field | Type | Description |
|---|---|---|
| event_idrequired | string | Hex ID of the event to repost |
| pubkeyrequired | string | Pubkey of the original author |
| relay_urlsoptional | string[] | Override default relays |
Send DM
Publishes a kind-4 encrypted direct message (NIP-04).
Request body
| Field | Type | Description |
|---|---|---|
| recipient_pubkeyrequired | string | Hex pubkey of the recipient |
| contentrequired | string | Plaintext message โ encrypted automatically |
| relay_urlsoptional | string[] | Override default relays |
Update Follow List
Publishes a kind-3 contact list (follow list). Replaces the existing follow list.
Request body
| Field | Type | Description |
|---|---|---|
| followsrequired | string[] | Array of hex pubkeys to follow |
| relay_urlsoptional | string[] | Override default relays |
Example
{
"follows": [
"abc123...",
"def456..."
]
}
Publish Raw Event
Publish any Nostr event kind. The event is signed automatically with your managed keypair (or your BYOK key).
Request body
| Field | Type | Description |
|---|---|---|
| kindrequired | integer | Nostr event kind number |
| contentrequired | string | Event content |
| tagsoptional | array[][] | Nostr tags array |
| relay_urlsoptional | string[] | 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
Query events from the relay using NIP-01 filter parameters.
Query parameters
| Param | Type | Description |
|---|---|---|
| kindsoptional | string | Comma-separated kind numbers (e.g. 1,6,7) |
| authorsoptional | string | Comma-separated hex pubkeys |
| sinceoptional | integer | Unix timestamp โ events after this time |
| untiloptional | integer | Unix timestamp โ events before this time |
| limitoptional | integer | Max results (default 20, max 100) |
| relay_urloptional | string | Relay 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
Fetch a single event by its hex ID.
Example
curl https://gateway.agilesolutionlabs.com/v1/events/abc123... \
-H "Authorization: Bearer nk_live_..."
Get Profile
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!"}'
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.
Usage Stats
Returns request counts and per-endpoint breakdown for the current API key.
Query parameters
| Param | Type | Description |
|---|---|---|
| periodoptional | string | today (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
}
}