Palindrome Checker API: The Complete Guide

Need to check if text is a palindrome? This guide covers everything you need to know about palindrome detection via API, including handling spaces, punctuation, and case sensitivity.

What is a Palindrome?

A palindrome is a word, phrase, number, or sequence of characters that reads the same forward and backward. When checking phrases, spaces and punctuation are typically ignored.

Examples: "racecar", "A man a plan a canal Panama", "12321"

Types of Palindromes

Different kinds of palindromes:

  • Word palindromes: "radar", "level", "civic"
  • Phrase palindromes: "Was it a car or a cat I saw?"
  • Number palindromes: "12321", "1001"
  • Sentence palindromes: "Never odd or even"
Note: Phrase palindromes typically ignore spaces, punctuation, and case. "A Santa at NASA" is a valid palindrome.

Using the Palindrome Checker API

TinyFn provides a simple endpoint to check palindromes:

API Request
POST https://api.tinyfn.io/v1/text/palindrome
Headers: X-API-Key: your-api-key
Content-Type: application/json

{
  "text": "A man a plan a canal Panama",
  "ignore_spaces": true,
  "ignore_case": true
}
Response
{
  "is_palindrome": true,
  "normalized": "amanaplanacanalpanama",
  "original": "A man a plan a canal Panama"
}

Parameters

Parameter Type Description
text string The text to check (required)
ignore_spaces boolean Ignore whitespace (default: true)
ignore_case boolean Case-insensitive check (default: true)
ignore_punctuation boolean Ignore punctuation marks (default: true)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/text/palindrome',
  {
    method: 'POST',
    headers: {
      'X-API-Key': 'your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      text: 'racecar',
      ignore_case: true
    })
  }
);
const result = await response.json();
console.log(result.is_palindrome); // true

Python

import requests

response = requests.post(
    'https://api.tinyfn.io/v1/text/palindrome',
    headers={'X-API-Key': 'your-api-key'},
    json={'text': 'racecar', 'ignore_case': True}
)
result = response.json()
print(result['is_palindrome'])  # True

cURL

curl -X POST "https://api.tinyfn.io/v1/text/palindrome" \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text": "racecar"}'

Common Use Cases

  • Word Games: Validate palindrome puzzles and games
  • Educational Apps: Teach palindrome concepts
  • Text Analysis: Find palindromes in documents
  • Fun Applications: Generate or validate palindromes
  • Programming Exercises: Verify algorithm implementations

Best Practices

  1. Normalize input: Usually ignore spaces and punctuation
  2. Handle Unicode: Consider accented characters properly
  3. Clear feedback: Show the normalized form for transparency
  4. Edge cases: Empty strings and single characters are palindromes

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-text": {
      "url": "https://api.tinyfn.io/mcp/text/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all text analysis tools available via MCP in our Text Analysis MCP Tools for AI Agents guide.

Try the Palindrome Checker API

Get your free API key and start checking palindromes in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key