NSFW Image Detector API - Ruby Gem

NSFW Detector is a simple tool for detecting NSFW content. It returns a boolean

Installation

Add this line to your application's Gemfile:

gem 'apiverve_nsfwimagedetector'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_nsfwimagedetector

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_nsfwimagedetector'

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

# Make a request
response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })

# Print the response
puts response

File Upload

# Upload a file
response = client.execute_with_file("/path/to/file.jpg")

# Or use a URL
response = client.execute_with_url("https://example.com/image.jpg")

Error Handling

begin
  response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })
  puts response["data"]
rescue APIVerve::Nsfwimagedetector::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Nsfwimagedetector::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "isNSFW": false,
    "isSafe": true,
    "confidence": 0.987,
    "category": "neutral"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.