api

package
v0.4.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientConnectHandler added in v0.4.12

func ClientConnectHandler(w http.ResponseWriter, r *http.Request)

ClientConnectHandler connects the client to a relay Usage: POST /api/v1/client/connect/relay.damus.io?read=true&write=false

func ClientDisconnectHandler added in v0.4.12

func ClientDisconnectHandler(w http.ResponseWriter, r *http.Request)

ClientDisconnectHandler disconnects the client from a relay Usage: POST /api/v1/client/disconnect/relay.damus.io

func ClientRelaysHandler added in v0.4.12

func ClientRelaysHandler(w http.ResponseWriter, r *http.Request)

ClientRelaysHandler returns the client's configured relays and their status Works with or without authentication - returns user relays if authenticated, app relays if not

func GetCacheHandler added in v0.4.1

func GetCacheHandler(w http.ResponseWriter, r *http.Request)

GetCacheHandler returns the cached user data as JSON (no session data) Automatically refreshes cache if expired or missing

func GetSessionHandler added in v0.4.1

func GetSessionHandler(w http.ResponseWriter, r *http.Request)

GetSessionHandler returns the current user's session data as JSON (auth state only)

func GetUserProfileHandler added in v0.4.1

func GetUserProfileHandler(w http.ResponseWriter, r *http.Request)

GetUserProfileHandler fetches user profile using core client

func GetUserRelaysHandler added in v0.4.1

func GetUserRelaysHandler(w http.ResponseWriter, r *http.Request)

GetUserRelaysHandler fetches user relay list using core client

func HandleAmberCallback added in v0.4.1

func HandleAmberCallback(w http.ResponseWriter, r *http.Request)

HandleAmberCallback processes callbacks from Amber app

func KeyDeriveHandler added in v0.4.12

func KeyDeriveHandler(w http.ResponseWriter, r *http.Request)

KeyDeriveHandler derives public key from private key

func KeyGenerationHandler added in v0.4.12

func KeyGenerationHandler(w http.ResponseWriter, r *http.Request)

KeyGenerationHandler generates a new random Nostr key pair

func KeyValidationHandler added in v0.4.12

func KeyValidationHandler(w http.ResponseWriter, r *http.Request)

KeyValidationHandler validates any key type (hex, npub, or nsec)

func LoginHandler added in v0.4.1

func LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler handles user login requests via API Initializes user by fetching mailboxes, setting app relays, getting metadata from outboxes, caching the data, and creating session with appropriate signing capabilities

func LogoutHandler added in v0.4.1

func LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler handles user logout requests via API

func PingHandler added in v0.4.12

func PingHandler(w http.ResponseWriter, r *http.Request)

PingHandler pings any relay and returns response time and connection status Now supports domain-in-path with auto ws/wss detection Usage: GET /api/v1/ping/relay.damus.io

func PrivateKeyConversionHandler added in v0.4.12

func PrivateKeyConversionHandler(w http.ResponseWriter, r *http.Request)

PrivateKeyConversionHandler converts between hex and nsec formats

func PublicKeyConversionHandler added in v0.4.12

func PublicKeyConversionHandler(w http.ResponseWriter, r *http.Request)

PublicKeyConversionHandler converts between hex and npub formats

func PublishEventHandler added in v0.4.1

func PublishEventHandler(w http.ResponseWriter, r *http.Request)

PublishEventHandler handles event publishing requests

func QueryEventsHandler added in v0.4.1

func QueryEventsHandler(w http.ResponseWriter, r *http.Request)

QueryEventsHandler handles event querying using core client

func RefreshCacheHandler added in v0.4.1

func RefreshCacheHandler(w http.ResponseWriter, r *http.Request)

RefreshCacheHandler manually refreshes cache for the current user

Types

type AmberCallbackData added in v0.4.1

type AmberCallbackData struct {
	Event     string `json:"event"`
	PublicKey string `json:"public_key"`
	Error     string `json:"error,omitempty"`
}

AmberCallbackData represents the callback data from Amber

type ClientRelaysResponse added in v0.4.12

type ClientRelaysResponse struct {
	Relays []RelayStatus `json:"relays"`
	Count  int           `json:"count"`
}

ClientRelaysResponse represents the response for client relays

type KeyGenerationResponse added in v0.4.12

type KeyGenerationResponse struct {
	PrivateKey string `json:"private_key,omitempty"` // hex format
	PublicKey  string `json:"public_key,omitempty"`  // hex format
	Nsec       string `json:"nsec,omitempty"`        // bech32 format
	Npub       string `json:"npub,omitempty"`        // bech32 format
	Error      string `json:"error,omitempty"`
}

KeyGenerationResponse represents the response structure for key generation

type KeyValidationResponse added in v0.4.12

type KeyValidationResponse struct {
	Valid bool   `json:"valid"`
	Type  string `json:"type"`
	Error string `json:"error,omitempty"`
}

KeyValidationResponse represents the response structure for key validation

type PublishEventRequest added in v0.4.1

type PublishEventRequest struct {
	Kind       int        `json:"kind"`
	Content    string     `json:"content"`
	Tags       [][]string `json:"tags,omitempty"`
	PrivateKey string     `json:"privateKey,omitempty"`
	Relays     []string   `json:"relays,omitempty"`
}

PublishEventRequest represents the request structure for publishing events

type PublishEventResponse added in v0.4.1

type PublishEventResponse struct {
	Success bool                   `json:"success"`
	EventID string                 `json:"eventId,omitempty"`
	Event   *nostr.Event           `json:"event,omitempty"`
	Results []core.BroadcastResult `json:"results"`
	Summary core.BroadcastSummary  `json:"summary"`
	Error   string                 `json:"error,omitempty"`
}

PublishEventResponse represents the response structure for publishing events

type RelayStatus added in v0.4.12

type RelayStatus struct {
	URL         string    `json:"url"`
	Connected   bool      `json:"connected"`
	Status      string    `json:"status"`
	Latency     *int64    `json:"latency,omitempty"` // Ping latency in milliseconds
	LastChecked time.Time `json:"last_checked"`
	Read        bool      `json:"read"`
	Write       bool      `json:"write"`
	AddedAt     time.Time `json:"added_at"`
}

RelayStatus represents the status of a relay connection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL