Palindrome Checker API - Ruby Gem
Palindrome Checker is a tool for checking if text is a palindrome. It supports options to ignore case, spaces, and punctuation, and finds the longest palindromic substring.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_palindromechecker'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_palindromechecker
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_palindromechecker'
# Initialize the client
client = APIVerve::Palindromechecker::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
text: "A man a plan a canal Panama",
ignorecase: true,
ignorespaces: true,
ignorepunctuation: true
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ text: "A man a plan a canal Panama", ignorecase: true, ignorespaces: true, ignorepunctuation: true })
puts response["data"]
rescue APIVerve::Palindromechecker::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Palindromechecker::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Palindromechecker::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"text": "A man a plan a canal Panama",
"is_palindrome": true,
"cleaned_text": "amanaplanacanalpanama",
"reversed_text": "amanaplanacanalpanama",
"length": 21,
"options": {
"ignore_case": true,
"ignore_spaces": true,
"ignore_punctuation": true
},
"longest_palindrome_substring": "amanaplanacanalpanama",
"longest_palindrome_length": 21
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/palindromechecker?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.