API Reference

API Reference

Integrate Redactorr into your applications with our browser-based API and JavaScript SDK.

🔌

Local-First API

The Redactorr Engine runs entirely in your browser. All processing happens locally on your device, with no data sent to external servers. The API is available through both a REST interface and the Redactorr JavaScript SDK for browser integration.

Getting Started

Prerequisites

  1. Download and install the Redactorr local runtime
  2. Start the runtime (it will listen on http://localhost:8765)
  3. Verify the runtime is running by accessing the health endpoint

# Check if runtime is running

curl http://localhost:8765/health

{"status": "ok", "version": "1.0.0"}

REST API Endpoints

POST/api/redact

Redact sensitive data from text or documents.

Request Body

{
  "content": "Customer john@example.com called about order #12345",
  "format": "text",
  "patterns": ["email", "all"],
  "options": {
    "preserveFormat": true,
    "customPatterns": []
  }
}

Response

{
  "redacted": "Customer [EMAIL_7f8a] called about order #12345",
  "tokens": [
    {
      "token": "[EMAIL_7f8a]",
      "type": "email",
      "position": { "start": 9, "end": 26 }
    }
  ],
  "metadata": {
    "detectionCount": 1,
    "processingTime": 12
  }
}
POST/api/reverse

Restore original values from tokenized content.

Request Body

{
  "content": "Customer [EMAIL_7f8a] called about order #12345",
  "sessionId": "550e8400-e29b-41d4-a716-446655440000"
}

Response

{
  "restored": "Customer john@example.com called about order #12345",
  "tokensRestored": 1
}
POST/api/detect

Detect sensitive data without redacting.

Request Body

{
  "content": "SSN: 123-45-6789, Card: 4532-1234-5678-9010",
  "patterns": ["ssn", "credit_card"]
}

Response

{
  "detections": [
    {
      "type": "ssn",
      "value": "123-45-6789",
      "confidence": 0.98,
      "position": { "start": 5, "end": 16 }
    },
    {
      "type": "credit_card",
      "value": "4532-1234-5678-9010",
      "confidence": 0.99,
      "position": { "start": 24, "end": 43 }
    }
  ]
}
GET/api/patterns

List all available detection patterns.

Response

{
  "patterns": [
    {
      "id": "email",
      "name": "Email Address",
      "category": "contact",
      "enabled": true
    },
    {
      "id": "ssn",
      "name": "Social Security Number",
      "category": "pii",
      "enabled": true
    }
  ]
}

JavaScript SDK

For browser-based applications, use the Redactorr SDK to run the Redactorr Engine directly in the browser with no server required.

Installation

npm install @redactorr/sdk

Usage Example

import { Redactorr } from '@redactorr/sdk';

// Initialize the Redactorr Engine
const redactorr = await Redactorr.init();

// Redact sensitive data
const result = redactorr.redact({
  content: "Email: john@example.com, SSN: 123-45-6789",
  patterns: ['email', 'ssn']
});

console.log(result.redacted);
// "Email: [EMAIL_7f8a], SSN: [SSN_9d1e]"

// Reverse redaction
const restored = redactorr.reverse({
  content: result.redacted,
  sessionId: result.sessionId
});

console.log(restored.content);
// "Email: john@example.com, SSN: 123-45-6789"

Integration Examples

📦Node.js / Express

const express = require('express');
const axios = require('axios');

const app = express();
app.use(express.json());

app.post('/redact', async (req, res) => {
  try {
    const response = await axios.post(
      'http://localhost:8765/api/redact',
      {
        content: req.body.text,
        patterns: ['email', 'ssn', 'credit_card']
      }
    );

    res.json(response.data);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

app.listen(3000);

🐍Python / FastAPI

from fastapi import FastAPI
import httpx

app = FastAPI()

@app.post("/redact")
async def redact_text(text: str):
    async with httpx.AsyncClient() as client:
        response = await client.post(
            "http://localhost:8765/api/redact",
            json={
                "content": text,
                "patterns": ["email", "ssn", "credit_card"]
            }
        )
        return response.json()

⚛️React / TypeScript

import { useState } from 'react';

function RedactorComponent() {
  const [text, setText] = useState('');
  const [redacted, setRedacted] = useState('');

  const handleRedact = async () => {
    const response = await fetch('http://localhost:8765/api/redact', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        content: text,
        patterns: ['email', 'ssn']
      })
    });

    const data = await response.json();
    setRedacted(data.redacted);
  };

  return (
    <div>
      <textarea value={text} onChange={(e) => setText(e.target.value)} />
      <button onClick={handleRedact}>Redact</button>
      <pre>{redacted}</pre>
    </div>
  );
}

Error Handling

The API returns standard HTTP status codes and error responses:

200
Success
Request completed successfully
400
Bad Request
Invalid request parameters
500
Internal Error
Processing error occurred
503
Service Unavailable
Local runtime not running

# Error response format

{
  "error": "Invalid pattern specified",
  "code": "INVALID_PATTERN",
  "details": "Pattern 'unknown_pattern' not found"
}

Performance & Limits

  • Max Document Size: 50MB per request
  • Concurrent Requests: Limited by your machine's resources
  • Processing Speed: ~1000 pages/second on average hardware
  • Token Storage: Unlimited (local storage only)

Learn More

Explore related documentation