{
  "openapi": "3.0.3",
  "info": {
    "title": "HTML to Markdown Converter",
    "version": "1.0.0",
    "description": "Convert HTML to clean Markdown using turndown. No external API dependency. Supports single and batch conversion (up to 10 documents) and a URL preview endpoint that fetches a page and returns its Markdown.\n",
    "contact": {
      "name": "HTML to Markdown API Support",
      "email": "api@hiroapp.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/markdown",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "tags": [
    {
      "name": "Convert"
    },
    {
      "name": "Preview"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "RapidApiProxy": []
    }
  ],
  "paths": {
    "/api/v1/convert": {
      "post": {
        "operationId": "convertHtmlToMarkdown",
        "summary": "Convert HTML to Markdown",
        "tags": [
          "Convert"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "html"
                ],
                "properties": {
                  "html": {
                    "type": "string",
                    "description": "HTML input (max 1 MB)"
                  },
                  "options": {
                    "type": "object",
                    "description": "turndown options"
                  }
                }
              },
              "example": {
                "html": "<h1>Title</h1><p>Hello <strong>world</strong></p>"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarkdownResult"
                },
                "example": {
                  "markdown": "# Title\n\nHello **world**"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/convert/batch": {
      "post": {
        "operationId": "convertHtmlToMarkdownBatch",
        "summary": "Convert multiple HTML documents (max 10)",
        "tags": [
          "Convert"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10,
                    "items": {
                      "type": "object",
                      "required": [
                        "html"
                      ],
                      "properties": {
                        "html": {
                          "type": "string"
                        },
                        "options": {
                          "type": "object"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/preview": {
      "get": {
        "operationId": "previewUrlAsMarkdown",
        "summary": "Fetch a URL and convert it to Markdown",
        "tags": [
          "Preview"
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "http/https URL to fetch and convert",
            "schema": {
              "type": "string"
            },
            "example": "https://example.com"
          },
          {
            "name": "clean",
            "in": "query",
            "required": false,
            "description": "Strip noise before conversion (default true)",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Markdown for the fetched page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarkdownResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/FetchFailed"
          },
          "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": {
      "MarkdownResult": {
        "type": "object",
        "properties": {
          "markdown": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Missing or invalid input",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "'html' is required"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "API key required"
            }
          }
        }
      },
      "TooLarge": {
        "description": "Input exceeds size limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "HTML exceeds 1MB limit"
            }
          }
        }
      },
      "FetchFailed": {
        "description": "URL could not be fetched",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Failed to fetch URL"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (100 requests per minute)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded"
            }
          }
        }
      }
    }
  }
}