http://localhost:3001/api
POST /api/keys/generateResponse:
{
"privateKey": "hex_private_key",
"publicKey": "hex_public_key",
"nsec": "nsec1...",
"npub": "npub1..."
}POST /api/keys/decode
Content-Type: application/json
{
"key": "nsec1... | npub1... | nprofile1..."
}Response for nsec:
{
"type": "nsec",
"privateKey": "hex_private_key",
"publicKey": "hex_public_key",
"nsec": "nsec1...",
"npub": "npub1..."
}Response for npub:
{
"type": "npub",
"publicKey": "hex_public_key",
"npub": "npub1..."
}POST /api/lightning/validate
Content-Type: application/json
{
"address": "user@domain.com"
}Response:
{
"valid": true,
"address": "user@domain.com",
"lnurlEndpoint": "https://domain.com/.well-known/lnurlp/user",
"callback": "https://domain.com/lnurl/pay/callback",
"minSendable": 1000,
"maxSendable": 100000000,
"allowsNostr": true,
"nostrPubkey": "hex_pubkey",
"metadata": [...]
}POST /api/events/publish
Content-Type: application/json
{
"privateKey": "nsec1... | hex_private_key",
"latitude": 40.7128,
"longitude": -74.0060,
"nickname": "MyNickname",
"message": "Hello from NYC!",
"lightningAddress": "user@domain.com" // optional
}Response:
{
"success": true,
"event": { /* full nostr event */ },
"npub": "npub1...",
"geohash": "dr5regy7",
"eventId": "event_hash"
}GET /api/heatmap-dataResponse:
[
{
"geohash": "dr5regy7",
"intensity": 100,
"count": 10,
"lastActivity": 1755875402
}
]GET /api/activityResponse:
[
{
"geohash": "dr5regy7",
"nickname": "TestUser",
"message": "Hello world!",
"timestamp": 1755875402,
"relay": "wss://relay.damus.io",
"lightningAddress": "user@domain.com",
"npub": "npub1..."
}
]POST /api/zaps/create-request
Content-Type: application/json
{
"senderPrivateKey": "nsec1... | hex_private_key",
"recipientPubkey": "hex_pubkey | npub1...",
"amount": "21000", // millisats
"message": "Great post!",
"eventId": "event_hash_to_zap", // optional
"relays": ["wss://relay.damus.io"] // optional
}Response:
{
"success": true,
"zapRequest": { /* NIP-57 zap request event */ },
"senderNpub": "npub1...",
"recipientNpub": "npub1..."
}GET /api/users/{npub}Response:
{
"npub": "npub1...",
"publicKey": "hex_public_key",
"activities": [
{
"geohash": "dr5regy7",
"nickname": "User",
"message": "Hello!",
"timestamp": 1755875402,
"lightningAddress": "user@domain.com"
}
],
"totalActivities": 25,
"lastActivity": 1755875402
}// Generate new keys
const response = await fetch('/api/keys/generate', { method: 'POST' });
const keys = await response.json();
console.log('Your nsec:', keys.nsec);
console.log('Your npub:', keys.npub);
// Decode existing key
const decodeResponse = await fetch('/api/keys/decode', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key: 'nsec1...' })
});
const decoded = await decodeResponse.json();const publishResponse = await fetch('/api/events/publish', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
privateKey: 'nsec1...',
latitude: 40.7128,
longitude: -74.0060,
nickname: 'MyNickname',
message: 'Hello from NYC!',
lightningAddress: 'myuser@domain.com'
})
});
const result = await publishResponse.json();const validateResponse = await fetch('/api/lightning/validate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ address: 'user@domain.com' })
});
const validation = await validateResponse.json();All endpoints return appropriate HTTP status codes with error messages:
{
"error": "Descriptive error message"
}Connect to: ws://localhost:3001
Incoming message format:
{
"type": "new_activity",
"data": {
"geohash": "dr5regy7",
"nickname": "User",
"message": "Hello!",
"timestamp": 1755875402,
"lightningAddress": "user@domain.com",
"npub": "npub1..."
}
}