Query Examples

sidebar_position: 3 title: Sample Queries

Querying

Below are some sample queries you can use to gather information from the Domains contracts.

You can build your own queries using a GraphQL Explorer and enter your endpoint to limit the data to exactly what you need.

Get the top domain for an account based on the longest registry.

query getDomainForAccount {
 account(id: "0xa508c16666c5b8981fa46eb32784fccc01942a71") {
   registrations(first: 1, orderBy: expiryDate, orderDirection: desc) {
     domain {
       name
     }
   }
   id
 }
}

Returns

{
 "data": {
   "account": {
     "registrations": [
       {
         "domain": {
           "name": "datanexus.tomi"
         }
       }
     ],
     "id": "0xa508c16666c5b8981fa46eb32784fccc01942a71"
   }
 }
}

Search for subdomain

query getSubDomains($Account: String = "messari.tomi") {
 domains(where: { name: "messari.tomi" }) {
   name
   id
   subdomains(first: 10) {
     name
   }
   subdomainCount
 }
}

Returns

{
 "data": {
   "domains": [
     {
       "name": "messari.tomi",
       "id": "0x498ada62251a1227664ace8d97b0de2dcc6652ddf61e6fb5d3150f43ccf599e6",
       "subdomains": [
         {
           "name": "subgraphs.messari.tomi"
         },
         {
           "name": "bd.messari.tomi"
         }
       ],
       "subdomainCount": 2
     }
   ]
 }
}

Get an expiration for an Domains domain

query getDomainExp($Account: String = "paulieb.tomi") {
 registrations(
   where: { domain_: { name: $Account } }
   first: 1
   orderBy: expiryDate
   orderDirection: desc
 ) {
   expiryDate
 }
}

Returns

{
 "data": {
   "registrations": [
     {
       "expiryDate": "1714752524"
     }
   ]
 }
}

Last updated