Text & strings

Template

Renders a template string with {{variable}} placeholders using a variables object. Supports dot notation for nested objects (e.g. {{user.name}}). Undefined variables remain as placeholders and are listed in `variables_missing`.

MCP tool: render_template

POST /v1/template/render

Parameters:

ParameterTypeRequiredDescription
templatestringTemplate string to render (max 100KB)
variablesobject-Variables object for substitution (defaults to empty object)

Request example:

curl -X POST "https://api.thousand-api.com/v1/template/render" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "Hello, {{name}}.",
    "variables": {"name": "Alice"}
  }'

Response example:

{
  "rendered": "Hello, Alice.",
  "variables_missing": []
}

Response:

When variables are undefined, placeholders remain in rendered and paths are listed in variables_missing. Numbers and booleans are converted to strings.

String Case

Convert between camel, snake, kebab, pascal, constant, title, and related cases. Input case is auto-detected. Use to=all to fetch all variants at once.

MCP tool: convert_string_case

GET /v1/string/case

Parameters:

ParameterTypeRequiredDescription
textstringString to convert
tostringcamel / snake / kebab / pascal / constant / title / lower / upper / all

Request example:

curl "https://api.thousand-api.com/v1/string/case?text=hello_world_foo&to=camel" \
  -H "x-api-key: YOUR_API_KEY"

Response example:

{
  "text": "hello_world_foo",
  "to": "camel",
  "detected_case": "snake",
  "result": "helloWorldFoo"
}

Response:

When to=all, result is an object keyed by case name. For strings containing non-ASCII characters (e.g. Japanese), only lower and upper are transformed; other cases return the input unchanged.

Random String

Generates cryptographically secure random strings. Configurable charset, length, and count. Uses Node.js built-in crypto.

MCP tool: generate_random_string

GET /v1/random/string

Parameters:

ParameterTypeRequiredDescription
lengthinteger-String length (default: 16, max: 128)
charsetstring-alphanumeric / alphabetic / numeric / hex / urlsafe / uppercase
countinteger-Number of strings to generate (default: 1, max: 10)

Request example:

curl "https://api.thousand-api.com/v1/random/string?length=8&charset=uppercase&count=3" \
  -H "x-api-key: YOUR_API_KEY"

Response example:

{
  "length": 8,
  "charset": "uppercase",
  "count": 3,
  "results": ["AB3K7MN2", "PQ9XL4WZ", "R7MN2PQ9"]
}

Response:

Generated strings are suitable for session tokens, temporary passwords, and invite codes. For production cryptographic keys, use purpose-appropriate key generation (e.g. crypto.generateKeyPair).

Text Stats

Extract plain text from HTML, return text statistics, compute line-based diffs, or generate URL-safe slugs from human-readable titles.

MCP tools: extract_text_from_html, get_text_stats, diff_text, generate_slug

POST /v1/text/html-to-text

Parameters:

ParameterTypeRequiredDescription
htmlstringHTML text to extract (max 1MB)
max_lengthinteger-Optional maximum character count for output (positive integer)
preserve_linksboolean-When true, return a list of { text, href } links (default false)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/html-to-text" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Hello</h1><p>Visit <a href=\"https://example.com\">Example</a></p>",
    "max_length": 500,
    "preserve_links": true
  }'

Response example:

{
  "text": "Hello\n\nVisit Example",
  "char_count": 19,
  "truncated": false,
  "links": [
    {
      "text": "Example",
      "href": "https://example.com"
    }
  ]
}

Response fields:

ParameterDescription
textPlain text with tags removed, entities decoded, and whitespace normalized
char_countCharacter count of text
truncatedTrue when max_length truncated the output
linksPresent only when preserve_links is true; array of { text, href }

Response:

script and style tags (including their contents) are removed entirely. Block elements (p, div, h1–h6, li, etc.) become line breaks; three or more consecutive newlines are compressed to two. Useful for reducing tokens from HTML fetched via the Scraper tool.

POST /v1/text/stats

Parameters:

ParameterTypeRequiredDescription
textstringText to analyze (max 100KB)
langstring-Language code (ja / en, default en)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/stats" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "AI agents need reliable MCP utilities.",
    "lang": "en"
  }'

Response example:

{
  "characters": 42,
  "characters_no_spaces": 37,
  "words": 7,
  "sentences": 1,
  "paragraphs": 1,
  "reading_time_seconds": 2
}

Response fields:

ParameterDescription
charactersTotal character count (includes spaces and newlines)
characters_no_spacesCharacter count excluding spaces, tabs, and newlines
wordsWord count (ja: non-whitespace characters; en: space-separated tokens)
sentencesSentence count (ja: 。!?; en: .!?)
paragraphsParagraph count (split on blank lines)
reading_time_secondsEstimated reading time in seconds (rounded up)

Response:

Reading speed: ja uses 500 characters/min (characters_no_spaces); en uses 225 words/min (words). No external APIs required.

POST /v1/text/diff

Parameters:

ParameterTypeRequiredDescription
originalstringOriginal text to compare (max 256KB)
modifiedstringModified text to compare against (max 256KB)
context_linesinteger-Context lines around changes (0–10, default 3)
formatstring-Output format (unified / json, default unified)

Example: format "unified" (unified diff string)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/diff" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "original": "line1\nline2\nline3\n",
    "modified": "line1\nline3\nline4\n",
    "context_lines": 3,
    "format": "unified"
  }'

Response example:

{
  "diff": "===================================================================\n@@ -1,3 +1,3 @@\n line1\n-line2\n line3\n+line4\n",
  "added_lines": 1,
  "removed_lines": 1,
  "has_changes": true
}

Example: format "json" (structured chunks)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/diff" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "original": "alpha\nbeta\n",
    "modified": "alpha\ngamma\n",
    "format": "json"
  }'

Response example:

{
  "diff": [
    { "type": "unchanged", "lines": ["alpha"] },
    { "type": "removed", "lines": ["beta"] },
    { "type": "added", "lines": ["gamma"] }
  ],
  "added_lines": 1,
  "removed_lines": 1,
  "has_changes": true
}

Response fields:

ParameterDescription
diffUnified diff string when format is unified (--- / +++ header lines removed), or an array of { type, lines } when format is json
added_linesNumber of lines added
removed_linesNumber of lines removed
has_changesTrue when any line was added or removed

Response:

Line-based diff. Useful for code review, comparing AI-generated text to the original, and summarizing document revisions. MCP tool: diff_text

POST /v1/text/slugify

Parameters:

ParameterTypeRequiredDescription
textstringText to slugify (max 1000 characters)
localestring-ja (default): romanize Japanese with Hepburn before slugify; en and others: skip romanization
separatorstring-Word separator (- / _ / ., default -)
max_lengthinteger-Maximum slug length (1–200)
lowercaseboolean-Lowercase the slug (default true)

convert_string_case (GET /v1/string/case) converts existing ASCII identifiers between camel, snake, kebab, and similar cases; Japanese only supports lower/upper. This API targets URL paths, document IDs, and navigation keys from human-readable titles, romanizing Japanese when locale is ja via kuromoji + kuroshiro before normalization.

MCP tool: generate_slug

Example 1: Japanese title (locale: ja)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/slugify" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Thousand API — 祝日カレンダー機能",
    "locale": "ja"
  }'

Response example:

{
  "input": "Thousand API — 祝日カレンダー機能",
  "slug": "thousand-api-shukujitsu-karendaa-kinou",
  "truncated": false,
  "char_replaced": ["—"]
}

Example 2: English text (locale: en)

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/slugify" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello World! This is a Test.",
    "locale": "en"
  }'

Response example:

{
  "input": "Hello World! This is a Test.",
  "slug": "hello-world-this-is-a-test",
  "truncated": false,
  "char_replaced": ["!", "."]
}

Example 3: separator and max_length

Request example:

curl -X POST "https://api.thousand-api.com/v1/text/slugify" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "My Long Document Title Here And More",
    "locale": "en",
    "separator": "_",
    "max_length": 30
  }'

Response example:

{
  "input": "My Long Document Title Here And More",
  "slug": "my_long_document_title_here",
  "truncated": true,
  "char_replaced": []
}

Response fields:

ParameterDescription
inputThe request text echoed back
slugGenerated URL-safe slug
truncatedTrue when max_length truncated the slug
char_replacedCharacters removed or replaced (unique, order of first appearance)

Response:

Japanese processing uses the same Lambda as /v1/ja/convert (kuromoji dictionary). The first request after a cold start may take several seconds.

Japanese Text Conversion

Convert Japanese text to hiragana, katakana, or romaji. Uses kuromoji morphological analysis for accurate conversion of proper nouns.

MCP tool: convert_japanese

GET /v1/ja/convert

Parameters:

ParameterTypeRequiredDescription
textstringJapanese text to convert (max 1000 characters)
tostringhiragana / katakana / romaji

Request example:

curl "https://api.thousand-api.com/v1/ja/convert?text=%E6%9D%B1%E4%BA%AC%E9%83%BD%E6%B8%8B%E8%B0%B7%E5%8C%BA&to=hiragana" \
  -H "x-api-key: YOUR_API_KEY"

Response example:

{
  "text": "東京都渋谷区",
  "to": "hiragana",
  "result": "とうきょうとしぶやく"
}

Regular Expression Tester

Tests a regular expression pattern against text and returns match results. Supports named capture groups and common flags. ReDoS protection included.

MCP tool: test_regex

POST /v1/regex/test

Parameters:

ParameterTypeRequiredDescription
patternstringRegular expression pattern without delimiters
textstringText to test (max 10,000 characters)
flagsstring-Combination of g / i / m / s / u

Request example:

curl -X POST "https://api.thousand-api.com/v1/regex/test" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pattern": "(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})",
    "text": "2026-05-29",
    "flags": ""
  }'

Response example:

{
  "pattern": "(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})",
  "flags": "",
  "text": "2026-05-29",
  "matched": true,
  "match_count": 1,
  "matches": [
    {
      "value": "2026-05-29",
      "index": 0,
      "groups": {
        "year": "2026",
        "month": "05",
        "day": "29"
      }
    }
  ]
}