ENSDb SQL
This page provides an overview of the ENSDb SQL interface and how to use it in your applications.
Example Queries
Section titled “Example Queries”Connect with Any PostgreSQL Client
Section titled “Connect with Any PostgreSQL Client”Connect to an ENSDb instance (a PostgreSQL database). The examples below assume you that ENSDb instances are served from a PostgreSQL server at host:5432 with databases named ensdb_mainnet, ensdb_testnet, and ensdb_devnet:
# Production environment (mainnet data)psql postgresql://user:password@host:5432/ensdb_mainnet
# Pre-production environment (testnet data)psql postgresql://user:password@host:5432/ensdb_testnet
# Staging / local development environmentpsql postgresql://user:password@host:5432/ensdb_devnetDiscover Available Schemas
Section titled “Discover Available Schemas”Once connected to an ENSDb instance, discover its ENSIndexer Schemas:
SELECT DISTINCT ens_indexer_schema_nameFROM ensnode.metadata;Query Data
Section titled “Query Data”Query data from your ENSDb instance:
-- Get domains from the ENSIndexer Schema with the `ensindexer_mainnet` ENSIndexer Schema NameSELECT * FROM ensindexer_mainnet.v1_domains LIMIT 10;
-- Get indexing status for the ENSNode Schema with the `ensindexer_mainnet` ENSIndexer Schema NameSELECT * FROM "ensnode"."metadata"WHERE ens_indexer_schema_name = 'ensindexer_mainnet'AND key = 'ensindexer_indexing_status'AND value -> 'data' -> 'omnichainSnapshot' ->> 'omnichainStatus' = 'omnichain-following';