{
  "openapi": "3.0.3",
  "info": {
    "title": "Domain Availability Checker API",
    "description": "Check domain availability via DNS lookups, get WHOIS information, and receive domain name suggestions. No external dependencies for DNS checks — uses Node.js built-in dns/promises.",
    "version": "1.0.0",
    "contact": {
      "name": "RevenueLab"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/domain",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "ApiKeyQuery": []
    },
    {
      "RapidAPIProxy": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "health",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "service": {
                      "type": "string",
                      "example": "domain-api"
                    },
                    "version": {
                      "type": "string",
                      "example": "1.0.0"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/check": {
      "get": {
        "summary": "Check domain availability",
        "description": "Checks if a domain is available by querying DNS A and MX records. A domain with no A or MX records is considered available.",
        "operationId": "checkDomain",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Domain name to check",
            "schema": {
              "type": "string",
              "example": "example.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Domain availability result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailabilityResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/check/bulk": {
      "post": {
        "summary": "Check multiple domains",
        "description": "Check availability for up to 10 domains in a single request.",
        "operationId": "checkBulk",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domains"
                ],
                "properties": {
                  "domains": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 10,
                    "example": [
                      "example.com",
                      "myapp.io"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk availability results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AvailabilityResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/whois": {
      "get": {
        "summary": "Get WHOIS information",
        "description": "Fetches WHOIS data for a domain including registrar, creation/expiration dates, and nameservers.",
        "operationId": "whoisLookup",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Domain name for WHOIS lookup",
            "schema": {
              "type": "string",
              "example": "example.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "WHOIS data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhoisResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/suggest": {
      "get": {
        "summary": "Get domain suggestions",
        "description": "Returns domain name suggestions for a keyword across popular TLDs (.com, .io, .dev, .app, .co, .net, .org, .me) with availability status.",
        "operationId": "suggestDomains",
        "parameters": [
          {
            "name": "keyword",
            "in": "query",
            "required": true,
            "description": "Keyword to build domain suggestions from",
            "schema": {
              "type": "string",
              "example": "myapp"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Domain suggestions with availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keyword": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "domain": {
                            "type": "string"
                          },
                          "available": {
                            "type": "boolean"
                          },
                          "estimatedPrice": {
                            "$ref": "#/components/schemas/Price"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AvailabilityResult": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "example": "example.com"
          },
          "available": {
            "type": "boolean",
            "example": false
          },
          "method": {
            "type": "string",
            "example": "dns"
          },
          "estimatedPrice": {
            "$ref": "#/components/schemas/Price"
          },
          "cached": {
            "type": "boolean"
          }
        }
      },
      "WhoisResult": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "available": {
            "type": "boolean"
          },
          "registrar": {
            "type": "string",
            "nullable": true
          },
          "creationDate": {
            "type": "string",
            "nullable": true
          },
          "expirationDate": {
            "type": "string",
            "nullable": true
          },
          "updatedDate": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "nameServers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "raw": {
            "type": "string"
          },
          "cached": {
            "type": "boolean"
          }
        }
      },
      "Price": {
        "type": "object",
        "properties": {
          "usd": {
            "type": "number",
            "example": 12.99
          },
          "currency": {
            "type": "string",
            "example": "USD"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing or invalid",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "ApiKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "api_key"
      },
      "RapidAPIProxy": {
        "type": "apiKey",
        "in": "header",
        "name": "x-rapidapi-proxy-secret"
      }
    }
  }
}