Phonetic Encoder API - Ruby Gem

Phonetic Encoder generates phonetic codes for words using Soundex and Metaphone algorithms. These codes represent how words sound, enabling fuzzy matching of similar-sounding names.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_phonetic'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_phonetic

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_phonetic'

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

# Make a request
response = client.execute({
  word: "smith",
  algorithm: "both"
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ word: "smith", algorithm: "both" })
  puts response["data"]
rescue APIVerve::Phonetic::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Phonetic::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "word": "smith",
    "soundex": "S530",
    "metaphone": "SM0"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.