URL Title API - Ruby Gem

URL Title is a simple tool for getting the title of a web page. It returns the title of the web page based on the URL provided.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_urltitle'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_urltitle

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_urltitle'

# Initialize the client
client = APIVerve::Urltitle::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ url: "https://blog.apiverve.com/chuck-norris-api-how-to" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ url: "https://blog.apiverve.com/chuck-norris-api-how-to" })
  puts response["data"]
rescue APIVerve::Urltitle::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Urltitle::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "title": "Chuck Norris API: How to Easily Add Jokes to Your App - APIVerve Blog",
    "h1": [
      "Chuck Norris API: How to Easily Add Jokes to Your App"
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.