Random Joke API - Ruby Gem

Random Joke is a simple tool for getting random jokes. It returns a random joke from a collection of jokes.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_randomjoke'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_randomjoke

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_randomjoke'

# Initialize the client
client = APIVerve::Randomjoke::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::Randomjoke::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Randomjoke::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "score": 7,
    "setup": "Why is the space between a woman's chest and her hips called a waist?",
    "punchline": "Because you could easily fit another pair of tits in there."
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.