DEV Community

Daniel Igel
Daniel Igel

Posted on

DNS lookup via REST API — resolve A, AAAA, MX, TXT, NS and CNAME records in your app

DNS queries in app code start simple and get awkward fast. You need A records for routing, TXT for ownership verification, MX for mail checks — each with different functions, different error shapes, and its own parsing logic.

One GET normalizes all of it:

curl --request GET \
  --url 'https://dns-lookup-api3.p.rapidapi.com/api/v1/lookup?domain=github.com&type=A' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: dns-lookup-api3.p.rapidapi.com'
Enter fullscreen mode Exit fullscreen mode

type accepts A, AAAA, MX, TXT, NS, CNAME, SOA, or PTR. Pass type=ALL for a combined A/AAAA/MX/TXT/NS/CNAME/SOA response in one round-trip. Every result has the same shape: domain, type, records, ttl. Results are cached for 5 minutes.

const res = await fetch(
  'https://dns-lookup-api3.p.rapidapi.com/api/v1/lookup?domain=example.com&type=TXT',
  { headers: { 'x-rapidapi-key': process.env.RAPIDAPI_KEY, 'x-rapidapi-host': 'dns-lookup-api3.p.rapidapi.com' } }
);
const { records } = await res.json(); // SPF, DKIM, DMARC, ownership tokens
Enter fullscreen mode Exit fullscreen mode

Need to check multiple domains at once? POST /api/v1/lookup/batch accepts up to 20 domain/type pairs in one round-trip — useful for CI pipelines or onboarding flows that verify domain ownership before provisioning. Reverse DNS is GET /api/v1/reverse?ip=8.8.8.8.

Built on Node.js dns/promises — no external service, no third-party quota.

Free tier on RapidAPI: https://rapidapi.com/danieligel/api/dns-lookup-api3

Which DNS record types do you query most from app code — A for routing, MX for mail checks, or TXT for verification tokens?

Top comments (0)