{
  "name": "epub-to-text",
  "summary": "Extracts an EPUB’s reading-order text and Dublin Core metadata, chapter by chapter.",
  "rationale": "Reading an EPUB means walking a zip, its container, its OPF spine and each XHTML chapter through a hardened fetch. An agent doing that inline walks past every SSRF control, and it is fiddly enough to be worth a paid endpoint.",
  "family": "documents",
  "price_usd": "0.005",
  "free": false,
  "timeout_ms": 45000,
  "max_timeout_seconds": 66,
  "input_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 2048,
        "format": "uri",
        "description": "Absolute http(s) URL of the .epub, up to 2048 characters; redirects are followed and the body must be a zip whose META-INF/container.xml points at an OPF package."
      },
      "max_chapters": {
        "default": 500,
        "description": "How many leading XHTML/HTML spine chapters to extract, 1 to 5000; a shorter book is not an error, and a longer one is cut and reported as truncated.",
        "type": "integer",
        "minimum": 1,
        "maximum": 5000
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/documents/seed-saving.epub",
    "max_chapters": 500
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/documents/seed-saving.epub",
    "metadata": {
      "title": "A Short Guide to Seed Saving",
      "creator": "Grist Samples",
      "language": "en"
    },
    "chapter_count": 3,
    "extracted_chapters": 3,
    "truncated": false,
    "chars": 441,
    "chapters": [
      {
        "href": "OEBPS/ch1.xhtml",
        "text": "Why Save Seeds\n\nSaving seeds keeps a variety that grows well in your own soil.\n\nIt also costs nothing and makes next spring easier to plan."
      },
      {
        "href": "OEBPS/ch2.xhtml",
        "text": "Choosing Plants\n\nPick the healthiest plants and let a few fruits ripen fully.\n\nBeans and peas are the easiest to start with.\n\nTomatoes need their seeds rinsed and dried."
      },
      {
        "href": "OEBPS/ch3.xhtml",
        "text": "Drying and Storing\n\nDry seeds on paper for a week, away from direct sun.\n\nStore them in labelled envelopes in a cool, dark place."
      }
    ],
    "text": "Why Save Seeds\n\nSaving seeds keeps a variety that grows well in your own soil.\n\nIt also costs nothing and makes next spring easier to plan.\n\nChoosing Plants\n\nPick the healthiest plants and let a few fruits ripen fully.\n\nBeans and peas are the easiest to start with.\n\nTomatoes need their seeds rinsed and dried.\n\nDrying and Storing\n\nDry seeds on paper for a week, away from direct sun.\n\nStore them in labelled envelopes in a cool, dark place."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}