1

I want to add ENS support to an app I am building, and I am looking for a lightweight API which supports ENS to Ethereum address conversion.

All the documentation shows how you can do this on the blockchain, and it appears like Web3.js will work, but I am wondering if there is anything more lightweight than this, like a public GET API which returns JSON.

3 Answers 3

0

I believe there is no API to have a ENS lookup, the only way you can get the address from ENS is calling the ENS contract.

0

Ethereum blockchain is accessed by JSON-RPC API that uses HTTP GET/POST as its transport.

To get a Ethereum JSON-RPC API node see https://ethereumnodes.com/

For example, Cloudflare offers a free API servers.

Then you can use a Web3.js/Ether.hs and ENS ABI files to call the smart contract to fetch the information. If you want to get more lightweight you can construct the same JSON-RPC HTTP calls by hand, but it is an unreadable mess and advised against, so don't do it.

-1

You can register an API key at https://etherscan.io/apis and call their JSON API. I think if you experiment a bit by calling the name service contract, you should be able to extract this information.

Specifically you can call the contract module via the getabi method, passing the contract address.

https://api.etherscan.io/api?\
module=account&\
action=balance&\
address=<your contract address>&\
tag=latest&\
apikey=<your API key>

You can simply use the ENS name instead of the address. This also works with the account module.

5
  • I must be blind. Where is the ens api mentioned in the documentation? Dec 12, 2017 at 10:00
  • If you like the answer, upvote it.
    – Mundi
    Dec 12, 2017 at 11:09
  • I'm sorry, I don't like the answer because I do not see evidence of an API at etherscan Dec 12, 2017 at 15:04
  • Hmmm, I included the link... Tell me how you want me to improve the answer rather than down-voting.
    – Mundi
    Dec 13, 2017 at 14:08
  • 1
    I did not down vote you. Others did for the same reason I did not accept your answer. Etherscan.io does not appear to expose a public API which resolves ens names. Show me where it does, and the documents in for it, and I will be happy to give you a positive vote. Dec 13, 2017 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.