{"openapi":"3.1.0","info":{"title":"SliceMD — Webpage to LLM Markdown & Token Counter API","version":"1.0.0","description":"Stateless API that turns a public webpage, or raw HTML, into clean Markdown, article metadata, and an o200k_base token count."},"servers":[{"url":"https://slicemd.p.rapidapi.com","description":"RapidAPI gateway"}],"components":{"securitySchemes":{"RapidAPIKey":{"type":"apiKey","in":"header","name":"X-RapidAPI-Key","description":"Your RapidAPI application key. Call the API through RapidAPI; direct calls to the Worker are rejected."},"RapidAPIHost":{"type":"apiKey","in":"header","name":"X-RapidAPI-Host","description":"The RapidAPI host for SliceMD, shown on the RapidAPI listing."}},"schemas":{"ExtractResult":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"url":{"type":["string","null"],"description":"Final URL after redirects, or null for raw HTML without a url"},"metadata":{"$ref":"#/components/schemas/ArticleMetadata"},"markdown":{"type":"string"},"stats":{"$ref":"#/components/schemas/ExtractStats"}},"required":["success","url","metadata","markdown","stats"]},"ArticleMetadata":{"type":"object","properties":{"title":{"type":["string","null"],"description":"Article or page title"},"description":{"type":["string","null"],"description":"Meta description or excerpt"},"author":{"type":["string","null"],"description":"Byline, when the page exposes one"},"site_name":{"type":["string","null"],"description":"Site name from Open Graph or the publisher"},"published_date":{"type":["string","null"],"description":"Published time as provided by the page"},"language":{"type":["string","null"],"description":"BCP 47 language tag"}},"required":["title","description","author","site_name","published_date","language"]},"ExtractStats":{"type":"object","properties":{"char_count":{"type":"integer","description":"Length of the returned Markdown"},"word_count":{"type":"integer"},"estimated_tokens":{"type":"integer","description":"Exact o200k_base token count of the returned Markdown. Not an estimate; the name is kept for compatibility."},"processing_time_ms":{"type":"integer"},"cached":{"type":"boolean","description":"True when this response was served from the Cache API"},"cached_at":{"type":["string","null"],"description":"ISO 8601 time the cached copy was stored. Null when the response was not served from cache."}},"required":["char_count","word_count","estimated_tokens","processing_time_ms","cached","cached_at"]},"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"ExtractRequest":{"type":"object","properties":{"url":{"type":"string","maxLength":2048,"format":"uri","description":"Absolute http(s) URL to fetch. Required when html is omitted."},"html":{"type":"string","maxLength":1000000,"description":"Raw HTML to convert instead of fetching, at most 1,000,000 characters. Required when url is omitted."},"include_links":{"type":"boolean","default":true,"description":"Keep hyperlinks in the Markdown"},"include_images":{"type":"boolean","default":false,"description":"Keep images in the Markdown"},"max_tokens":{"type":"integer","minimum":0,"maximum":200000,"description":"When set, truncate Markdown on a paragraph or word boundary within this o200k_base budget"},"cache_ttl":{"type":"integer","minimum":0,"maximum":3600,"default":3600,"description":"Maximum age in seconds of a cached copy this request accepts, and how long a fresh fetch is stored. 0 bypasses the cache. URLs with a query string are not cached. Ignored for raw HTML."}},"additionalProperties":false,"anyOf":[{"required":["url"]},{"required":["html"]}]},"BatchExtractResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"total":{"type":"integer"},"succeeded":{"type":"integer"},"failed":{"type":"integer"},"results":{"type":"array","items":{"anyOf":[{"$ref":"#/components/schemas/BatchItemSuccess"},{"$ref":"#/components/schemas/BatchItemFailure"}]},"description":"One item per input URL, in request order"}},"required":["success","total","succeeded","failed","results"]},"BatchItemSuccess":{"allOf":[{"$ref":"#/components/schemas/ExtractResult"},{"type":"object","properties":{"index":{"type":"integer","description":"Position of this URL in the request urls array"},"input_url":{"type":"string","description":"The URL exactly as sent in the request"}},"required":["index","input_url"]}]},"BatchItemFailure":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"index":{"type":"integer","description":"Position of this URL in the request urls array"},"input_url":{"type":"string","description":"The URL exactly as sent in the request"},"url":{"type":["string","null"],"description":"Same as input_url"},"status":{"type":"integer","description":"HTTP status this URL would have returned from POST /v1/extract"},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","index","input_url","url","status","error"]},"BatchExtractRequest":{"type":"object","properties":{"urls":{"type":"array","items":{"type":"string","maxLength":2048,"format":"uri"},"minItems":1,"maxItems":10,"description":"Absolute http(s) URLs, at most 10"},"include_links":{"type":"boolean","default":true},"include_images":{"type":"boolean","default":false},"max_tokens":{"type":"integer","minimum":0,"maximum":200000,"description":"When set, truncate Markdown on a paragraph or word boundary within this o200k_base budget"},"cache_ttl":{"type":"integer","minimum":0,"maximum":3600,"default":3600,"description":"Maximum age in seconds of a cached copy this request accepts, and how long a fresh fetch is stored. 0 bypasses the cache. URLs with a query string are not cached. Ignored for raw HTML."}},"required":["urls"],"additionalProperties":false}},"parameters":{}},"paths":{"/health":{"get":{"tags":["Health"],"summary":"Service health","responses":{"200":{"description":"SliceMD is ready","content":{"application/json":{"schema":{"type":"object","properties":{"service":{"type":"string","enum":["SliceMD"]},"status":{"type":"string","enum":["ok"]},"timestamp":{"type":"string"}},"required":["service","status","timestamp"]}}}}}}},"/v1/extract":{"post":{"tags":["Extract"],"summary":"Extract Markdown from a URL or raw HTML","description":"Fetches a public http(s) URL, or converts HTML you already have, into normalized Markdown plus metadata and token stats. URL responses without a query string are cached for at most one hour. Raw HTML is never cached.","security":[{"RapidAPIKey":[],"RapidAPIHost":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractRequest"}}}},"responses":{"200":{"description":"Markdown, metadata, and token stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractResult"}}}},"400":{"description":"The request was invalid, the URL was rejected, or the host is blocked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"RapidAPI credentials missing or incorrect","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"The request body or the fetched HTML exceeded the size limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"415":{"description":"Content-Type was not application/json, or the URL did not return HTML","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests. Retry after the number of seconds in the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Unexpected server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"The URL could not be fetched, or its host could not be resolved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Rate limiting is not configured on this deployment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"504":{"description":"The URL timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/extract/batch":{"post":{"tags":["Extract"],"summary":"Extract Markdown for up to 10 URLs","description":"Fetches every URL concurrently. Each URL has an 8 second timeout and its own success or error result, so one failure does not fail the batch. Every result carries the index and input_url it answers, and failures carry the HTTP status the single-URL endpoint would return. Batches have a tighter rate limit than single extractions.","security":[{"RapidAPIKey":[],"RapidAPIHost":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchExtractRequest"}}}},"responses":{"200":{"description":"Per-URL results. The batch itself succeeds even when some URLs fail.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchExtractResponse"}}}},"400":{"description":"The request body was invalid. Per-URL failures are reported inside a 200 response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"RapidAPI credentials missing or incorrect","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"Request body exceeded the size limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"415":{"description":"Content-Type was not application/json","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests. Retry after the number of seconds in the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Unexpected server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Rate limiting is not configured on this deployment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"webhooks":{}}