Punycode Converter API - Ruby Gem

Convert between Unicode and Punycode for internationalized domain names (IDN).

Installation

Add this line to your application's Gemfile:

gem 'apiverve_punycode'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_punycode

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_punycode'

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

# Make a request
response = client.execute({
  text: "münchen.de",
  mode: "encode"
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ text: "münchen.de", mode: "encode" })
  puts response["data"]
rescue APIVerve::Punycode::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Punycode::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "input": "münchen.de",
    "output": "xn--mnchen-3ya.de",
    "mode": "encode",
    "isIDN": true,
    "scripts": [
      "Latin"
    ],
    "mixedScript": false
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.