{
  "openapi": "3.0.3",
  "info": {
    "title": "DNS Lookup API",
    "version": "1.0.0",
    "description": "DNS record lookups via Node.js built-in dns/promises — no external API dependencies. Supports A, AAAA, MX, TXT, NS, CNAME, SOA, PTR record types, an ALL shortcut that queries all types in parallel, dedicated MX lookup with priority sorting, reverse DNS (IP → hostname), and batch queries for up to 20 domain/type pairs.\n",
    "contact": {
      "name": "DNS Lookup API Support",
      "email": "api@hiroapp.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/dns",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "tags": [
    {
      "name": "Lookup",
      "description": "Single DNS record queries"
    },
    {
      "name": "Batch",
      "description": "Bulk DNS queries"
    },
    {
      "name": "Reverse",
      "description": "Reverse DNS lookup"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "RapidApiProxy": []
    }
  ],
  "paths": {
    "/api/v1/lookup": {
      "get": {
        "operationId": "lookupDns",
        "summary": "Look up DNS records for a domain",
        "description": "Query a specific DNS record type for a domain. Use `type=ALL` to retrieve A, AAAA, MX, TXT, NS, CNAME, and SOA records in a single call.\n",
        "tags": [
          "Lookup"
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Domain name to look up",
            "schema": {
              "type": "string"
            },
            "example": "example.com"
          },
          {
            "name": "type",
            "in": "query",
            "required": true,
            "description": "DNS record type (A, AAAA, MX, TXT, NS, CNAME, SOA, PTR, or ALL)",
            "schema": {
              "type": "string",
              "enum": [
                "A",
                "AAAA",
                "MX",
                "TXT",
                "NS",
                "CNAME",
                "SOA",
                "PTR",
                "ALL"
              ]
            },
            "example": "A"
          }
        ],
        "responses": {
          "200": {
            "description": "DNS lookup result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DnsResult"
                },
                "examples": {
                  "a_record": {
                    "summary": "A record lookup",
                    "value": {
                      "domain": "example.com",
                      "type": "A",
                      "records": [
                        "93.184.216.34"
                      ]
                    }
                  },
                  "mx_record": {
                    "summary": "MX record lookup",
                    "value": {
                      "domain": "example.com",
                      "type": "MX",
                      "records": [
                        {
                          "exchange": "mail.example.com",
                          "priority": 10
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/DnsFailed"
          }
        }
      }
    },
    "/api/v1/mx": {
      "get": {
        "operationId": "lookupMx",
        "summary": "Look up MX records with priority",
        "description": "Returns MX records for a domain sorted by priority (lowest first).",
        "tags": [
          "Lookup"
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Domain name",
            "schema": {
              "type": "string"
            },
            "example": "gmail.com"
          }
        ],
        "responses": {
          "200": {
            "description": "MX records",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MxResult"
                },
                "example": {
                  "domain": "gmail.com",
                  "records": [
                    {
                      "exchange": "alt1.gmail-smtp-in.l.google.com",
                      "priority": 5
                    },
                    {
                      "exchange": "gmail-smtp-in.l.google.com",
                      "priority": 10
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/DnsFailed"
          }
        }
      }
    },
    "/api/v1/reverse": {
      "get": {
        "operationId": "reverseDns",
        "summary": "Reverse DNS lookup (IP → hostname)",
        "description": "Look up the hostname(s) registered for an IP address via PTR records.",
        "tags": [
          "Reverse"
        ],
        "parameters": [
          {
            "name": "ip",
            "in": "query",
            "required": true,
            "description": "IPv4 or IPv6 address",
            "schema": {
              "type": "string"
            },
            "example": "8.8.8.8"
          }
        ],
        "responses": {
          "200": {
            "description": "Reverse DNS result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReverseResult"
                },
                "example": {
                  "ip": "8.8.8.8",
                  "hostnames": [
                    "dns.google"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/DnsFailed"
          }
        }
      }
    },
    "/api/v1/lookup/batch": {
      "post": {
        "operationId": "lookupDnsBatch",
        "summary": "Batch DNS lookups",
        "description": "Execute up to 20 DNS queries in a single request. Each query is independent.",
        "tags": [
          "Batch"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "queries"
                ],
                "properties": {
                  "queries": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "required": [
                        "domain",
                        "type"
                      ],
                      "properties": {
                        "domain": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "A",
                            "AAAA",
                            "MX",
                            "TXT",
                            "NS",
                            "CNAME",
                            "SOA",
                            "PTR",
                            "ALL"
                          ]
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "queries": [
                  {
                    "domain": "example.com",
                    "type": "A"
                  },
                  {
                    "domain": "gmail.com",
                    "type": "MX"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch DNS results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchDnsResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "RapidApiProxy": {
        "type": "apiKey",
        "in": "header",
        "name": "x-rapidapi-proxy-secret"
      }
    },
    "schemas": {
      "DnsResult": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "records": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object"
                }
              ]
            }
          }
        }
      },
      "MxRecord": {
        "type": "object",
        "properties": {
          "exchange": {
            "type": "string"
          },
          "priority": {
            "type": "integer"
          }
        }
      },
      "MxResult": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MxRecord"
            }
          }
        }
      },
      "ReverseResult": {
        "type": "object",
        "properties": {
          "ip": {
            "type": "string"
          },
          "hostnames": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BatchDnsResultItem": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "records": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object"
                }
              ]
            }
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "BatchDnsResult": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchDnsResultItem"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request — missing or invalid parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "'domain' query parameter is required"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "API key required"
            }
          }
        }
      },
      "DnsFailed": {
        "description": "DNS lookup failed (upstream DNS error)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "DNS lookup failed"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (100 requests per minute)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded"
            }
          }
        }
      }
    }
  }
}