Documentation

Basic technical documentation for integrating Nodping with your website or app.

2. Nodping Accounts

The Nodping API keys allow external servers and client applications to securely fetch a user's Nodping username, Nodping number, and Nostr public identifier using a user-generated value. At the time of writing, you can replace 'nodping.app' with '581881.xyz' as a fallback for personal non-commercial use.

Architecture

Endpoint

GET https://nodping.app/api/v1/verify

Request

Header Value Format Requirement Description
Authorization Bearer np_live_<64-hex-chars> Required Your user's API key.
Origin https://example.com Optional Checked only if Origin-based restrictions are set on the key.
cURL Example
curl -X GET https://nodping.app/api/v1/verify \
  -H "Authorization: Bearer np_live_4f8b2c1a890123456789abcdef0123456789abcdef0123456789abcdef012345"

Responses

Success Response (200 OK)
{
  "valid": true,
  "username": "alice",
  "nodping_number": "10042",
  "npub": "npub1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqp87vvd",
  "created_at": 1791480000000
}
Error Responses
// 401 Unauthorized (Invalid format, unknown key, or revoked key)
{ "valid": false, "error": "Invalid API key." }

// 403 Forbidden (Origin or IP not permitted)
{ "valid": false, "error": "This domain name or IP address is not allowed for this key." }

// 429 Too Many Requests (Rate limit exceeded)
{ "valid": false, "error": "Too many requests for this key.", "retryAfter": 45 }

Backend

Node.js Implementation
import fetch from "node-fetch";

async function verifyNodpingUser(apiKey, serviceOrigin = null) {
  // Validate exact format: np_live_ + 64 hex characters (72 chars total)
  if (!/^np_live_[0-9a-fA-F]{64}$/.test(apiKey)) {
    throw new Error("Invalid key format: expected np_live_ prefix with 64 hex characters.");
  }

  const headers = {
    Authorization: `Bearer ${apiKey}`,
  };
  if (serviceOrigin) {
    headers["Origin"] = serviceOrigin;
  }

  const response = await fetch("https://nodping.app/api/v1/verify", {
    method: "GET",
    headers,
  });

  if (response.status === 401) {
    throw new Error("Invalid or revoked Nodping API key.");
  }
  if (response.status === 403) {
    throw new Error("Origin or IP address is not authorized for this Nodping key.");
  }
  if (response.status === 429) {
    const retryAfter = response.headers.get("retry-after") || 60;
    throw new Error(`Rate limit reached. Retry after ${retryAfter} seconds.`);
  }
  if (!response.ok) {
    throw new Error(`Verification failed with HTTP ${response.status}`);
  }

  return await response.json();
}