API Documentation

advertisement

API Documentation

Getting Started

Our comprehensive RESTful API provides seamless programmatic access to various classical cipher operations, including the Caesar cipher, ROT13 transformation, and the polyalphabetic Vigenère cipher. Designed specifically for educational purposes, this API is completely free to use and perfect for students, educators, developers, and cryptography enthusiasts. Whether you're building educational applications, conducting research, or simply exploring the fascinating world of historical cryptography, our API offers robust functionality with intelligent auto-solving capabilities and support for multiple languages and custom alphabets.

Base URL: https://caesar-cipher.com/api/v1

Content-Type: application/json

Rate Limit: 60 requests/minute

Key Benefits

Our API stands out with its educational focus, comprehensive documentation, and developer-friendly design. All endpoints return detailed responses with educational context, making it perfect for learning environments. The built-in frequency analysis and automatic cipher-breaking capabilities provide valuable insights into cryptanalysis techniques.

🎓 Educational Focus

Designed specifically for learning environments with comprehensive educational context and examples.

🔍 Auto-Solving

Intelligent frequency analysis and automatic cipher-breaking capabilities for research and learning.

🌍 Multi-Language

Support for multiple alphabets including Polish, German, Spanish, French, and custom alphabets.

📚 Free & Open

Completely free for educational and research purposes with comprehensive documentation.

Caesar Cipher

Encrypt Text

POST /api/v1/caesar/encrypt

Request Body:

{
  "text": "Hello World",
  "shift": 3,
  "alphabet": "basic",  // optional: basic, polish, german, spanish, french, custom
  "custom_alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",  // required if alphabet is "custom"
  "preserve_case": true,  // optional, default: true
  "preserve_non_alpha": true  // optional, default: true
}

Response:

{
  "success": true,
  "result": "Khoor Zruog",
  "method": "encrypt",
  "shift": 3,
  "alphabet": "basic",
  "text_length": 11
}

Decrypt Text

POST /api/v1/caesar/decrypt

Request Body:

{
  "text": "Khoor Zruog",
  "shift": 3,
  "alphabet": "basic"
}

Response:

{
  "success": true,
  "result": "Hello World",
  "method": "decrypt",
  "shift": 3,
  "alphabet": "basic",
  "text_length": 11
}

Auto-Solve Caesar Cipher

POST /api/v1/caesar/solve

Request Body:

{
  "text": "Khoor Zruog",
  "alphabet": "basic",  // optional
  "language": "en"  // optional: en, pl, de, es, fr
}

Response:

{
  "success": true,
  "best_solution": {
    "shift": 3,
    "text": "Hello World",
    "confidence": 95
  },
  "all_solutions": [
    {"shift": 3, "text": "Hello World", "score": 95.2},
    {"shift": 7, "text": "Dahhk Sknhz", "score": 42.1},
    ...
  ],
  "alphabet": "basic",
  "language": "en"
}

Bulk Processing

POST /api/v1/caesar/bulk

Request Body:

{
  "items": [
    {"text": "Hello", "shift": 3},
    {"text": "World", "shift": 5}
  ],
  "method": "encrypt",  // encrypt, decrypt, or solve
  "alphabet": "basic"
}

Response:

{
  "success": true,
  "method": "encrypt",
  "alphabet": "basic",
  "count": 2,
  "results": [
    {"index": 0, "original": "Hello", "result": "Khoor", "shift": 3},
    {"index": 1, "original": "World", "result": "Btwqi", "shift": 5}
  ]
}

ROT13

Transform Text

POST /api/v1/rot13/transform

Request Body:

{
  "text": "Hello World",
  "preserve_case": true,
  "preserve_non_alpha": true
}

Response:

{
  "success": true,
  "result": "Uryyb Jbeyq",
  "method": "rot13",
  "text_length": 11
}

Bulk ROT13

POST /api/v1/rot13/bulk

Request Body:

{
  "items": ["Hello", "World", "ROT13"],
  "preserve_case": true
}

Response:

{
  "success": true,
  "method": "rot13",
  "count": 3,
  "results": [
    {"index": 0, "original": "Hello", "result": "Uryyb"},
    {"index": 1, "original": "World", "result": "Jbeyq"},
    {"index": 2, "original": "ROT13", "result": "EBG13"}
  ]
}

Vigenère Cipher

Encrypt with Vigenère

POST /api/v1/vigenere/encrypt

Request Body:

{
  "text": "Hello World",
  "key": "KEY",
  "preserve_case": true,
  "preserve_non_alpha": true
}

Response:

{
  "success": true,
  "result": "Rijvs Uyvjn",
  "method": "encrypt",
  "key_length": 3,
  "text_length": 11
}

Analyze & Break Vigenère

POST /api/v1/vigenere/analyze

Request Body:

{
  "text": "RIJVS UYVJN RIJVS UYVJN...", // Long encrypted text
  "max_key_length": 10  // optional, default: 10
}

Response:

{
  "success": true,
  "analysis": {
    "probable_key_lengths": [3, 6, 9],
    "best_key_length": 3,
    "ioc_scores": {"1": 0.043, "2": 0.045, "3": 0.065},
    "probable_key": "KEY",
    "decrypted_preview": "HELLO WORLD HELLO WORLD..."
  },
  "text_length": 100
}

Code Examples

JavaScript / Node.js

// Caesar Cipher Encryption
const response = await fetch('https://caesar-cipher.com/api/v1/caesar/encrypt', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Hello World',
    shift: 3,
    alphabet: 'basic'
  })
});

const data = await response.json();
console.log(data.result); // "Khoor Zruog"

Python

import requests

# ROT13 Transform
response = requests.post('https://caesar-cipher.com/api/v1/rot13/transform',
    json={
        'text': 'Hello World',
        'preserve_case': True
    })

data = response.json()
print(data['result'])  # "Uryyb Jbeyq"

cURL

# Vigenère Cipher Encryption
curl -X POST https://caesar-cipher.com/api/v1/vigenere/encrypt \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello World",
    "key": "SECRET",
    "preserve_case": true
  }'

PHP

// Caesar Cipher Solver
$data = [
    'text' => 'Khoor Zruog',
    'alphabet' => 'basic',
    'language' => 'en'
];

$options = [
    'http' => [
        'header'  => "Content-type: application/json\r\n",
        'method'  => 'POST',
        'content' => json_encode($data)
    ]
];

$context  = stream_context_create($options);
$result = file_get_contents('https://caesar-cipher.com/api/v1/caesar/solve', false, $context);
$response = json_decode($result, true);

echo $response['best_solution']['text']; // "Hello World"

Error Handling

The API uses standard HTTP status codes and returns JSON error messages.

Common Status Codes:

  • 200 OK - Request successful
  • 400 Bad Request - Invalid parameters
  • 422 Unprocessable Entity - Validation errors
  • 429 Too Many Requests - Rate limit exceeded
  • 500 Internal Server Error - Server error

Error Response Format:

{
  "success": false,
  "error": "Validation error",
  "errors": {
    "text": ["The text field is required."],
    "shift": ["The shift must be between -25 and 25."]
  }
}

Rate Limiting

The API is rate-limited to 60 requests per minute per IP address. Rate limit information is included in response headers. When the limit is exceeded, you will receive a 429 status code with details:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58

# When rate limit is exceeded (HTTP 429):
{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. You can make up to 60 requests per minute.",
  "retry_after": 60,
  "documentation": "https://caesar-cipher.com/api-docs"
}

For higher rate limits or commercial use, please use the contact form on our website.

Ready to Get Started?

Start exploring our API today! Test the endpoints directly, integrate them into your applications, or use our interactive web tools to better understand classical cryptography.