Search Names
Search Names
This GET route fetches all names (subdomains) for a domain that start with a string. Ordered alphabetically.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
domain | string | Yes | The domain (e.g. "testbrand.eth"). |
name | string | Yes | The string names will start with. For example, 'ro' will return 'rob', 'robert', etc. |
text_records | 1 or 0 | No | Whether or not the route returns text records. 1 by default. |
limit | integer | No | Number of names returned in request. Default 50. |
exact_match | 1 or 0 | No | Route will only return names that are an exact match. |
offset | integer | No | Offset the returned names window. Default 0. |
Curl Example
curl -X GET \
-H 'Authorization: YOUR_API_KEY' \
'https://namestone.com/api/public_v1/search-names?domain=example.xyz&name=ro'
SDK Example
import NameStone, { AuthenticationError, NetworkError, NameData } from '@namestone/namestone-sdk';
// Initialize the NameStone instance
const ns = new NameStone(<YOUR_API_KEY_HERE>);
// Define the search parameters
const domain = "example.xyz";
const name = "ro";
// Use an immediately invoked async function to allow top-level await
(async () => {
try {
const response: NameData[] = await ns.searchNames({domain:domain, name:name});
if (response.length > 0) {
console.log(`Found ${response.length} name(s) matching the search criteria:`);
response.forEach((nameData, index) => {
console.log(`\nResult ${index + 1}:`);
console.log(JSON.stringify(nameData, null, 2));
});
} else {
console.log(`No names found matching '${name}' in the domain '${domain}'.`);
}
} 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);
}
}
})();
Example Return
[
{
"name":"robert",
"address":"0x57632Ba9A844af0AB7d5cdf98b0056c8d87e3A85",
"domain":"testbrand.eth",
"textRecords":{
"avatar":"https://imagedelivery.net/UJ5oN2ajUBrk2SVxlns2Aw/71cec612-fe0b-46a4-3d1c-e3eaf53d4600/public",
"com.twitter":"namestonehq",
"com.discord":"superslobo",
"location":"📍 nyc",
"url":"https://namestone.com",
"description":"Brand Choice"
}
}
]