Color Converter API - Ruby Gem
Color Converter is a simple tool for converting color formats. It returns the color converted to the specified format.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_colorconverter'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_colorconverter
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_colorconverter'
# Initialize the client
client = APIVerve::Colorconverter::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ hex: "FF0000" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ hex: "FF0000" })
puts response["data"]
rescue APIVerve::Colorconverter::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Colorconverter::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Colorconverter::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"hex": "#FF0000",
"rgb": "255, 0, 0",
"hsl": "0, 100, 50",
"cmyk": "0, 100, 100, 0",
"ansi16": 91,
"name": "red",
"channels": {
"rgbChannels": 3,
"cmykChannels": 4,
"ansiChannels": 1,
"hexChannels": 1,
"hslChannels": 3
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/colorconverter?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.