Text to Color API - Ruby Gem

Text to Color is a simple tool for converting color from natural language. It returns the color code based on the text provided.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_texttocolor'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_texttocolor

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_texttocolor'

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

# Make a request
response = client.execute({ color: "turquoise" })

# Print the response
puts response

Error Handling

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

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "color": "turquoise",
    "hex": "#66c8b8",
    "rgb": "102, 200, 184",
    "hsl": "170, 47, 59",
    "cmyk": "49, 0, 8, 22",
    "ansi16": 96,
    "channels": {
      "rgbChannels": 3,
      "cmykChannels": 4,
      "ansiChannels": 1,
      "hexChannels": 1,
      "hslChannels": 3
    }
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.