Catalog/text-truncate-words

Text

Truncate on word API

Truncates text to a maximum length on a word boundary and appends an ellipsis, never cutting mid-word and accounting for the ellipsis length. Answers 'how do I shorten this to N chars cleanly?', 'how do I add a … without breaking a word?'.

Price$0.01per request
MethodPOST
Route/v1/text/truncate-words
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
texttruncateellipsisshortenword-boundaryformattingpreviewsummary
API URLhttps://x402.hexl.dev/v1/text/truncate-words
Integration docs
Example request
{
  "text": "the quick brown fox jumps",
  "maxLength": 15
}
Example response
{
  "truncated": "the quick…",
  "wasTruncated": true,
  "length": 10,
  "originalLength": 25
}
Input schema
{
  "type": "object",
  "required": [
    "text",
    "maxLength"
  ],
  "properties": {
    "text": {
      "type": "string",
      "examples": [
        "the quick brown fox jumps"
      ]
    },
    "maxLength": {
      "type": "number",
      "examples": [
        15
      ]
    },
    "ellipsis": {
      "type": "string",
      "examples": [
        "…"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}