URL Unshortener API - Ruby Gem

URL Unshortener is a simple tool for unshortening shortened URLs. It returns the original URL before it was shortened.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_urlunshortener'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_urlunshortener

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_urlunshortener'

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

# Make a request
response = client.execute({ url: "https://bit.ly/3k3j4" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ url: "https://bit.ly/3k3j4" })
  puts response["data"]
rescue APIVerve::Urlunshortener::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Urlunshortener::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "source": "https://bit.ly/3k3j4",
    "destination": "http://www.allclimbing.com/archive/2009/09/climbing-video-alex-puccio-on-trice-v12/",
    "unshortened": true,
    "reason": null,
    "redirectCount": 1,
    "destinationDomain": "www.allclimbing.com",
    "redirectChain": [
      "https://bit.ly/3k3j4",
      "http://www.allclimbing.com/archive/2009/09/climbing-video-alex-puccio-on-trice-v12/"
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.