Advice Generator API - Ruby Gem
Advice Generator is a simple tool for generating random pieces of advice. It returns a random piece of advice.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_advice'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_advice
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_advice'
# Initialize the client
client = APIVerve::Advice::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute
# Print the response
puts response
Error Handling
begin
response = client.execute({ })
puts response["data"]
rescue APIVerve::Advice::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Advice::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Advice::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"id": "3xx4VZSZ",
"advice": "Be creative and innovative.",
"lang": "en"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/advice?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.