Service APIs

Intelligent spell checking to improve query quality and help users find what they're looking for

Overview

Brave Search Spell Check API provides advanced spell checking capabilities for search queries. It analyzes queries to detect spelling errors and suggests corrected alternatives, helping users get better search results even when they make typos or spelling mistakes.

Key Features

Query Correction

Automatically detect and correct spelling errors in search queries

Contextual Suggestions

Intelligent corrections based on query context and search patterns

Fast Response

Low-latency spell checking for real-time query processing

Language Support

Multi-language spell checking with country-specific corrections

API Reference

Spell Check API Documentation

View the complete API reference, including endpoints, parameters, and example requests

Use Cases

Spell Check API is perfect for:

  • Search Applications: Improve user experience by correcting typos before searching
  • Query Suggestions: Offer spelling corrections in search interfaces
  • Data Quality: Clean and normalize user-generated queries
  • Autocorrect: Implement “Did you mean?” functionality
  • Query Analysis: Identify and track common misspellings

Endpoint

Brave Spell Check API is available at the following endpoint:

https://api.search.brave.com/res/v1/spellcheck/search

To try the API on a Free plan, you’ll still need to subscribe — you simply won’t be charged. Once subscribed, you can get an API key in the API Keys section.

Getting Started

Get started immediately with a simple cURL request:

curl "https://api.search.brave.com/res/v1/spellcheck/search?q=helo&country=US" \
  -H "X-Subscription-Token: <YOUR_API_KEY>"

Example Response

{
  "type": "spellcheck",
  "query": {
    "original": "helo"
  },
  "corrected": {
    "query": "hello",
    "altered": true
  }
}

Common Examples

No Correction Needed

When the query is already spelled correctly:

curl "https://api.search.brave.com/res/v1/spellcheck/search?q=hello&country=US" \
  -H "X-Subscription-Token: <YOUR_API_KEY>"

Response:

{
  "type": "spellcheck",
  "query": {
    "original": "hello"
  },
  "corrected": {
    "query": "hello",
    "altered": false
  }
}

Multi-word Correction

The API handles corrections in multi-word queries:

curl "https://api.search.brave.com/res/v1/spellcheck/search?q=articifial+inteligence&country=US" \
  -H "X-Subscription-Token: <YOUR_API_KEY>"

Response:

{
  "type": "spellcheck",
  "query": {
    "original": "articifial inteligence"
  },
  "corrected": {
    "query": "artificial intelligence",
    "altered": true
  }
}

Integration Examples

async function checkSpelling(query, country = "US") {
  const params = new URLSearchParams({
    q: query,
    country: country,
  });

  const response = await fetch(
    `https://api.search.brave.com/res/v1/spellcheck/search?${params}`,
    {
      headers: {
        Accept: "application/json",
        "Accept-Encoding": "gzip",
        "X-Subscription-Token": "YOUR_API_KEY",
      },
    }
  );

  return await response.json();
}

// Usage
const result = await checkSpelling("helo world");
if (result.corrected.altered) {
  console.log(`Did you mean: ${result.corrected.query}?`);
}
import requests

def check_spelling(query: str, country: str = "US"):
    url = "https://api.search.brave.com/res/v1/spellcheck/search"

    headers = {
        "Accept": "application/json",
        "Accept-Encoding": "gzip",
        "X-Subscription-Token": "YOUR_API_KEY"
    }

    params = {
        "q": query,
        "country": country
    }

    response = requests.get(url, headers=headers, params=params)
    return response.json()

# Usage
result = check_spelling("helo world")
if result["corrected"]["altered"]:
    print(f"Did you mean: {result['corrected']['query']}?")

Best Practices

User Experience

  • Show Suggestions Gracefully: Display “Did you mean?” suggestions without forcing corrections
  • Preserve User Intent: Allow users to search for their original query if desired
  • Highlight Differences: Visually indicate which parts of the query were corrected

Performance Optimization

  • Debounce Requests: Implement debouncing (e.g., 200-300ms) to avoid excessive API calls
  • Cache Results: Cache spell check results for frequently typed queries
  • Async Loading: Check spelling asynchronously without blocking user input

Integration Patterns

// Debounced spell check implementation
function debounce(func, wait) {
  let timeout;
  return function executedFunction(...args) {
    const later = () => {
      clearTimeout(timeout);
      func(...args);
    };
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
  };
}

const debouncedSpellcheck = debounce(async (query) => {
  const result = await checkSpelling(query);
  if (result.corrected.altered) {
    // Show correction suggestion
    showSuggestion(result.corrected.query);
  }
}, 300);

// Call on input change
inputElement.addEventListener("input", (e) => {
  debouncedSpellcheck(e.target.value);
});

Rate Limiting

  • Implement client-side throttling to avoid hitting API rate limits
  • Consider combining spell check with other search operations
  • Monitor your API usage and adjust debounce timings accordingly

Changelog

This changelog outlines all significant changes to the Brave Search Spell Check API in chronological order.

  • 2023-05-01 Initial launch of Brave Search Spell Check API