Anagram Detector API - Ruby Gem

Anagram Detector is a tool for checking if two words or phrases are anagrams of each other. It provides character frequency analysis and similarity scoring.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_anagramdetector'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_anagramdetector

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_anagramdetector'

# Initialize the client
client = APIVerve::Anagramdetector::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  text1: "listen",
  text2: "silent",
  ignorecase: true,
  ignorespaces: true
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ text1: "listen", text2: "silent", ignorecase: true, ignorespaces: true })
  puts response["data"]
rescue APIVerve::Anagramdetector::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Anagramdetector::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Anagramdetector::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "text1": "listen",
    "text2": "silent",
    "is_anagram": true,
    "cleaned_text1": "listen",
    "cleaned_text2": "silent",
    "sorted_text1": "eilnst",
    "sorted_text2": "eilnst",
    "length_text1": 6,
    "length_text2": 6,
    "similarity_percentage": 100
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.