SDK Quickstart
SDK Quickstart
This guide helps you get started with our TypeScript SDK if you prefer type-safe methods. Each of our API pages includes an SDK example. Visit the SDK GitHub for more information.
Setup
Install the SDK through npm:
npm install @namestone/namestone-sdk
Initialize the Namestone client:
import NameStone, {
AuthenticationError,
NetworkError,
NameData,
} from "@namestone/namestone-sdk";
const ns = new NameStone("YOUR_API_KEY_HERE");
Then call with the relevant methods:
const domain = "testbrand.eth";
// Use an immediately invoked async function to allow top-level await
(async () => {
try {
const response: NameData[] = await ns.getNames({ domain: domain });
console.log(response);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Authentication failed:", error.message);
} else if (error instanceof NetworkError) {
console.error("Network error:", error.message);
} else {
console.error("An unexpected error occurred:", error);
}
}
})();