Fortune Cookie Generator API - Ruby Gem
Fortune Cookie Generator creates authentic fortune cookie messages including wisdom, predictions, advice, humor, and motivational quotes.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_fortunecookie'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_fortunecookie
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_fortunecookie'
# Initialize the client
client = APIVerve::Fortunecookie::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::Fortunecookie::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Fortunecookie::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Fortunecookie::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"fortune": "The best time to plant a tree was 20 years ago. The second best time is now.",
"type": "wisdom"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/fortunecookie?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.