Random Pun API - Ruby Gem

Random Pun is a simple tool for getting random puns. It returns a random pun from a collection of puns.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_randompun'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_randompun

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_randompun'

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

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "category": "Family, Parents",
    "rating": 2,
    "pun": "There was this guy who decided he wanted to live with his gay friends in a nudest colony and so he up and quit his job, and moved. He was really happy until he got a letter from his grandma. She told him he was about to die and wanted a picture of him. He got his friend to take a picture of him, and sice he had no clothes, he cut the picture in half. A few weeks later he received another letter from his grandma telling him he needed to get a haircut because it made his nose look long.... he soon realized he had sent her the wrong half."
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.