TypoCraft API

HTTP interface for the TypoCraft text de-polisher. Base URL: https://typocraft.nch.dev. Each request may include up to 5000 characters of text.

POST /transform

Send a JSON body with the text to process and optional knobs that affect probabilities. The response contains the original text, the transformed text, and mutation stats.

Request

POST https://typocraft.nch.dev/transform
Content-Type: application/json

{
  "text": "Hello — world 🙂", // required, up to 5000 chars
  "options": { // optional tuning block
    "typo_rate": 35, // global chance to attempt typos
    "remove_emoji": true,
    "remove_punctuation": 4, // probability to drop punctuation marks
    "format_relaxation": 60,
    "tone_relaxation": 35,
    "normalize_punctuation": true,
    "swap_probability": 8,
    "duplicate_probability": 4,
    "omit_probability": 6,
    "extra_space_probability": 8,
    "word_split_probability": 4,
    "decapitalize_probability": 6,
    "seed": 42 // deterministic random seed
  }
}
        

Response

{
  "data": {
    "original": "Hello — world 🙂", // untouched input
    "transformed": "Hello-  world", // processed output
    "stats": { // counters for each mutation
      "swaps": 0,
      "duplicates": 0,
      "omissions": 0,
      "brokenWords": 0,
      "extraSpaces": 1,
      "decapitalized": 0,
      "punctuationRemoved": 0,
      "formattingTweaks": 1,
      "toneTweaks": 0,
      "emojisRemoved": 2
    }
  }
}
        

Errors

400 (missing text / malformed JSON / text > 5000 chars)

413 (payload exceeds 250 KB)

500 (unexpected server error)