BCorrect™ Spelling & Grammar API — Complete Technical Reference (v1.2.0)

Machine-readable full documentation for AI agents, LLMs, and developers. Canonical HTML Docs: https://badcharacterscanner.com/api/docs RapidAPI Docs: https://badcharacterscanner.com/api/docs/rapidapi OpenAPI 3.1 Spec: https://badcharacterscanner.com/openapi.json Engine Versions & Known Issues: https://badcharacterscanner.com/api/versions


1. Overview

BCorrect™ is a deterministic spelling and grammar correction REST, SSE, and WebSocket API powered by the FMM (Fractal Morphological Machine) self-adaptive H-Manifold™ geometric engine.

Key guarantees:

  • Deterministic: Identical input and options always produce the exact same corrections. No generative hallucinations or unauthorized rewrites of authorial voice.
  • Ultra-Low Latency: Sub-15ms internal server-side processing on pure CPU hardware (fast profile <20ms P95, standard ~30-50ms P95).
  • Zero Data Retention: All submitted payloads are processed strictly in volatile RAM and purged immediately upon serialization. Payloads are never written to disk, logged, or used for training.
  • Universal Cognitive Resilience: Handles severe phonetic misspellings, keyboard transpositions, homophones, distributive subject-verb agreement, modal auxiliary complements, and compound pronoun case while preserving code blocks, LaTeX math, CLI flags, environment variables, and protected terms.
  • Engine Parity: Direct API (Stripe credits) and RapidAPI Hub run the exact same v1.2.0 production engine core.

2. Base URLs & Authentication

Direct API (Stripe Credit Packs)

  • Base URL: https://bcorrect-api.fly.dev/api/v1
  • WebSocket URL: wss://bcorrect-api.fly.dev/ws/keystroke
  • Auth Header: X-API-Key: sk_YOUR_KEY_HERE
  • Content-Type: application/json

RapidAPI Hub Gateway

  • Base URL: https://bcorrect-api.p.rapidapi.com/api/v1
  • Marketplace URL: https://rapidapi.com/BCSC/api/bcorrect-api
  • Auth Headers:
    • X-RapidAPI-Key: YOUR_RAPIDAPI_KEY
    • X-RapidAPI-Host: bcorrect-api.p.rapidapi.com
  • Content-Type: application/json

Note: GET /api/v1/health requires no authentication on the Direct API. All other endpoints require valid authentication headers.


3. Quick Start Examples

cURL (Direct API)

# 1. Health check (no auth required)
curl https://bcorrect-api.fly.dev/api/v1/health

# 2. Spell and grammar check
curl -X POST https://bcorrect-api.fly.dev/api/v1/check \
  -H "X-API-Key: sk_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Yesturday I went to the store and boughtt some groceries.",
    "mode": "correct",
    "profile": "standard",
    "exact_quotes": ["CustomTerm"],
    "options": {
      "dialect": "us",
      "max_candidates": 5,
      "include_diagnostics": true,
      "include_readability": true
    }
  }'

cURL (RapidAPI)

curl -X POST "https://bcorrect-api.p.rapidapi.com/api/v1/check" \
  -H "Content-Type: application/json" \
  -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: bcorrect-api.p.rapidapi.com" \
  -d '{
    "text": "Yesterday I go to school and seen my freind.",
    "mode": "correct",
    "profile": "standard",
    "exact_quotes": [],
    "options": {
      "dialect": "us",
      "max_candidates": 3,
      "include_diagnostics": true,
      "include_readability": true
    }
  }'

Python (requests)

import os
import requests

API_KEY = os.environ["BCORRECT_API_KEY"]
API_BASE = "https://bcorrect-api.fly.dev/api/v1"

res = requests.post(
    f"{API_BASE}/check",
    headers={
        "Content-Type": "application/json",
        "X-API-Key": API_KEY,
    },
    json={
        "text": "Yesturday I went to the store and boughtt some groceries.",
        "mode": "correct",
        "profile": "standard",
        "exact_quotes": ["CustomTerm"],
        "options": {
            "dialect": "us",
            "max_candidates": 5,
            "include_diagnostics": True,
            "include_readability": True,
        },
    },
    timeout=30,
)
res.raise_for_status()
data = res.json()
print("Corrected:", data["correctedText"])
print("Corrections:", data["corrections"])

JavaScript / TypeScript (fetch)

const res = await fetch("https://bcorrect-api.fly.dev/api/v1/check", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": process.env.BCORRECT_API_KEY!,
  },
  body: JSON.stringify({
    text: "Yesturday I went to the store and boughtt some groceries.",
    mode: "correct",
    profile: "standard",
    exact_quotes: ["CustomTerm"],
    options: {
      dialect: "us",
      max_candidates: 5,
      include_diagnostics: true,
      include_readability: true,
    },
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data.correctedText);

4. Operational Profiles & Output Modes

Profiles (profile)

All profiles run against the full H-Manifold™ vocabulary and differ only in search depth and latency budget:

  • standard (default): Multi-pass relaxation, sentence + paragraph context, ~30-50ms P95. Best for web textareas, editors, email, and customer support.
  • fast: Streamlined beam search, sliding token window, <20ms P95. Best for keystroke extensions, live autocomplete, chat, and mobile keyboards.
  • deep: Combinatorial multi-pass, cross-document global context, ~150-200ms P95. Best for long-form manuscripts, publishing proofs, and technical docs.
  • academic: 1.5x grammatical concord weight, formal register and citation shield, ~80-100ms P95. Best for scholarly papers, legal drafts, and formal documents.

Output Modes (mode)

  • correct (default): Executes the full 5-phase pipeline and returns correctedText, position-mapped corrections, diagnostics, optional readability/clarity metrics, and ranked candidates.
  • candidates: Returns ranked candidate suggestion lists for each flagged token, ideal for interactive dropdowns and underline popovers.

Dialect Support (options.dialect)

  • Auto-detected by default across English variants.
  • Explicit override values: "us" (American: color, realize), "uk" (British: colour, realise), "ca" (Canadian: colour, realize), "au" (Australian).
  • For short texts under 10 words, pass options.dialect explicitly for deterministic regional spelling.

5. REST, SSE & WebSocket Endpoints

5.1 GET /api/v1/health

Returns engine health, version, vocabulary size, and uptime. No authentication required.

Example response (200 OK):

{
  "status": "healthy",
  "version": "1.2.0",
  "uptime_seconds": 21281,
  "dictionary_loaded": true,
  "fractal_engine_ready": true,
  "vocabulary_size": 850000
}

5.2 POST /api/v1/check

Primary spelling and grammar correction endpoint.

Request body fields:

  • text (string, required, max 5MB): Input text to evaluate.
  • mode ("correct" | "candidates", optional, default "correct").
  • profile ("standard" | "fast" | "deep" | "academic", optional, default "standard").
  • exact_quotes (string[], optional): Brand names, identifiers, or custom terms shielded from modification.
  • options (object, optional):
    • dialect ("us" | "uk" | "ca" | "au", optional; auto-detected when omitted)
    • confidence_threshold (number, 0.0 to 1.0, default 0.75)
    • max_candidates (integer, default 10): Ranked alternatives returned per correction in a single roundtrip.
    • style_preservation ("standardize" | "preserve", default "standardize")
    • include_diagnostics (boolean, default true): Include explanations, educational tips, and rule IDs.
    • include_readability (boolean, default false): Include Flesch Reading Ease, Flesch-Kincaid Grade, Gunning Fog Index, and reading time.
    • include_clarity (boolean, default false): Include pleonasm and concision suggestions.
    • ignore_quoted_text (boolean, default false)
    • ignore_bracketed_text (boolean, default true)
    • ignore_math_blocks (boolean, default true): Preserves LaTeX and mathematical expressions verbatim.
    • ignore_code_blocks (boolean, default true): Preserves inline code and fenced code blocks.
    • ignore_markdown_urls (boolean, default true)
    • retrospective_corrections (boolean, default true)
    • include_geometric_info (boolean, default false)

Example response (200 OK):

{
  "originalText": "He woudl of avoided the severe mistakes if he was more careful.",
  "correctedText": "He would have avoided the severe mistakes if he was more careful.",
  "corrections": [
    {
      "original": "woudl",
      "corrected": "would",
      "confidence": 0.99,
      "positionInOriginal": { "start": 3, "end": 8 },
      "positionInCorrected": { "start": 3, "end": 8 },
      "source": "Dictionary",
      "category": "Spelling",
      "errorType": "PhoneticTransposition",
      "subtype": "PhoneticLetterSwap",
      "explanation": "Transposition error corrected to 'would'.",
      "educationalTip": "Remember the auxiliary sequence 'w-o-u-l-d'.",
      "candidates": [
        { "word": "would", "confidence": 0.99, "source": "NGram-Tree" }
      ]
    },
    {
      "original": "of",
      "corrected": "have",
      "confidence": 0.98,
      "positionInOriginal": { "start": 9, "end": 11 },
      "positionInCorrected": { "start": 9, "end": 13 },
      "source": "Grammar",
      "category": "Grammar",
      "errorType": "GrammaticalFunctionWord",
      "subtype": "ModalAuxiliaryComplement",
      "explanation": "Use modal auxiliary complement 'have' rather than preposition 'of'.",
      "educationalTip": "Spoken 'would've' sounds like 'would of', but writes 'would have'.",
      "candidates": [
        { "word": "have", "confidence": 0.98, "source": "Grammar" }
      ]
    }
  ],
  "charCount": 63,
  "processingMs": 16.16,
  "hasHomoglyphs": false,
  "telemetry": {
    "engineProcessingTimeUs": 16160,
    "engineProcessingTimeMs": 16.16,
    "wordsEvaluated": 11,
    "charactersEvaluated": 63,
    "fmmFlowRegime": "Laminar"
  },
  "readability": {
    "wordCount": 11,
    "sentenceCount": 1,
    "characterCount": 63,
    "fleschReadingEase": 75.2,
    "fleschKincaidGrade": 5.4,
    "gunningFogIndex": 6.1,
    "readingTimeSeconds": 3.0,
    "readingLevel": "Standard"
  },
  "creditsRemaining": 49937
}

Correction source values:

  • Dictionary: Direct misspelling correction
  • Grammar: Grammar rule (subject-verb, articles, auxiliaries)
  • SteinerGrammar: Geometric grammar detection
  • Style: Stylistic concision
  • Homophone: Homophone disambiguation (there/their/they're)
  • Fractal: Manifold-based correction
  • NGram: Context-based correction
  • CaseNorm: Capitalization fix
  • WordSplit: Missing space fix

5.3 POST /api/v1/batch

Parallel spell and grammar checking for up to 50 texts in a single call.

Request body:

{
  "texts": ["ths is a tset", "speling mistakke"],
  "profile": "standard",
  "options": { "dialect": "us" }
}

5.4 POST /api/v1/check/stream (SSE)

Server-Sent Events progressive chunked checking for long documents. Emits event: chunk frames with chunk_index, total_chunks, original_text, corrected_text, corrections, and latency_ms, followed by event: done.

5.5 WS /ws/keystroke (WebSocket)

Persistent bidirectional WebSocket protocol for live editors (<5ms per sliding window).

Client frame:

{
  "session_id": "c62b9a71-8b20-4e3e",
  "text": "The quick brown fox jumps ovr",
  "cursor_idx": 29,
  "is_terminal": false,
  "retrospective_corrections": true
}

Server frame:

{
  "session_id": "c62b9a71-8b20-4e3e",
  "corrections": [
    { "original": "ovr", "replacement": "over", "confidence": 0.99, "error_type": "Spelling" }
  ],
  "latency_us": 1280
}

5.6 GET /api/v1/usage

Returns credit balance, daily/monthly character usage, and quota percentages. Requires authentication.

Example response (200 OK):

{
  "key_tier": "pro",
  "credit_balance_cents": 500,
  "credit_balance_dollars": 5.00,
  "chars_today": 1200,
  "chars_this_month": 45000,
  "daily_quota": 50000,
  "monthly_quota": 250000,
  "daily_pct_used": 2.4,
  "monthly_pct_used": 18.0
}

5.7 GET /api/v1/monitoring/reynolds

Returns fluid-dynamic manifold stability telemetry (reynolds_number, is_turbulent, severity, breaker_state, pattern_density, correction_velocity, context_length).


6. Integration Best Practices & Error Handling

HTTP Status Codes

  • 200 OK: Successful evaluation.
  • 400 Bad Request: Invalid JSON payload or missing required text field.
  • 401 Unauthorized: Missing or invalid X-API-Key / X-RapidAPI-Key.
  • 402 Payment Required: Credit balance exhausted.
  • 429 Too Many Requests: Rate limit or quota exceeded; back off and retry.
  • 502 Bad Gateway / 503 Service Unavailable: Fly.io instance warming up (Retry-After: 3). Wait 3 seconds and retry up to 2 times.

Critical Frontend / Client Rules

  1. UTF-8 Byte Offsets: positionInOriginal and positionInCorrected are UTF-8 byte offsets from the Rust backend, not JavaScript UTF-16 code unit indices. Convert byte offsets using TextEncoder before slicing strings containing emojis, accented letters, or curly quotes.
  2. Right-to-Left Replacement: Sort corrections descending by positionInOriginal.start before applying in-place string replacements to prevent index drift.
  3. Single-Trip Candidates: Pass options.max_candidates (e.g., 5) with mode: "correct" to get both corrected text and ranked alternatives in one call.
  4. Debounce Live Editors: Debounce typing requests by 400-800ms and cancel stale in-flight requests using AbortController.
  5. Protect Brand Names: Pass custom names or domain slugs in exact_quotes instead of writing post-processing regexes.
  6. Keep Keys Server-Side: Proxy browser requests through a backend route so X-API-Key is never exposed to clients.

7. Pricing, Privacy & Support

  • Starter: $5 for 2M characters ($0.0025 / 1K chars)
  • Pro: $20 for 25M characters ($0.0008 / 1K chars)
  • Pro+: $100 for 120M characters ($0.00083 / 1K chars)
  • Enterprise: Custom volume rates (shoy@badcharacterscanner.com)
  • Privacy: Zero data retention, ephemeral volatile RAM only, never trained on customer payloads. Aligned with Canada PIPEDA, UK GDPR, EU GDPR & EU AI Act, and US CCPA/CPRA.
  • Support & Defect Reports: https://badcharacterscanner.com/contact or shoy@badcharacterscanner.com