Loading…
From zero to your first signed API call in under 10 minutes. No approval needed for sandbox.
✓ A partner account (apply at /partners/apply).
✓ Sandbox credentials issued by name.ai: a key id (pk_sandbox_…) and secret (sk_sandbox_…).
✓ Node.js 18+ or Python 3.9+ on your machine.
Never hardcode credentials. Store them server-side only.
export NAMEAI_KEY_ID="pk_sandbox_your_key_id_here"
export NAMEAI_API_SECRET="sk_sandbox_your_secret_here"All requests must be signed with HMAC-SHA256. Copy this helper once — you'll reuse it for every call. Full details: Authentication.
import crypto from "crypto";
const EMPTY_SHA256 = crypto.createHash("sha256").update("").digest("hex");
function canonicalizeQuery(searchParams) {
const params = Array.from(
(searchParams instanceof URLSearchParams ? searchParams : new URLSearchParams(searchParams || "")).entries()
);
return params
.sort(([a], [b]) => a.localeCompare(b))
.map(([k, v]) => {
const enc = (s) => encodeURIComponent(s).replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
return enc(k) + "=" + enc(v);
})
.join("&");
}
export function signRequest({ secret, method, url, body = "", timestamp, nonce }) {
const u = new URL(url);
const bodyHash = body ? crypto.createHash("sha256").update(body, "utf8").digest("hex") : EMPTY_SHA256;
const canonical = [method.toUpperCase(), u.pathname, canonicalizeQuery(u.searchParams), timestamp, nonce, bodyHash].join("\n");
const sig = crypto.createHmac("sha256", secret).update(canonical, "utf8").digest("hex");
return "v1=" + sig;
}Search the DSN for available domains. Scope required: search.
import crypto from "crypto";
import { signRequest } from "./sign.mjs";
import { buildPageMetadata } from '@/lib/seo/page-metadata';
const KEY_ID = process.env.NAMEAI_KEY_ID;
const SECRET = process.env.NAMEAI_API_SECRET;
const BASE = "https://name-stage.vps4.auctionhacker.com"; // swap for name.ai in production
const url = `${BASE}/api/partner/v1/domains/search?q=ai`;
const ts = String(Math.floor(Date.now() / 1000));
const nonce = crypto.randomUUID();
const sig = signRequest({ secret: SECRET, method: "GET", url, body: "", timestamp: ts, nonce });
const res = await fetch(url, {
headers: {
"X-NameAI-Key-Id": KEY_ID,
"X-NameAI-Timestamp": ts,
"X-NameAI-Nonce": nonce,
"X-NameAI-Signature": sig,
},
});
console.log(await res.json());Expected response shape:
{
"query": "ai",
"count": 3,
"results": [
{ "domain": "buildinai.com", "bin_price": 450000, "currency": "USD", "available": true },
{ "domain": "launchwithai.com", "bin_price": 250000, "currency": "USD", "available": true }
]
}You collect payment from the buyer. Next: MoR order flow →
Name.ai collects payment. Next: Pay with name.ai →
When you are ready to serve real buyers, contact name.ai to have live credentials issued. Switch your key id/secret from pk_sandbox_ / sk_sandbox_ to pk_live_ / sk_live_. No code changes required — the API paths are identical.