TOTP Generator API - Ruby Gem

TOTP Generator creates time-based one-time passwords compatible with authenticator apps using standard TOTP algorithms.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_totpgenerator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_totpgenerator

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_totpgenerator'

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

# Make a request
response = client.execute({
  secret: "JBSWY3DPEHPK3PXP",
  digits: 6,
  period: 30
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ secret: "JBSWY3DPEHPK3PXP", digits: 6, period: 30 })
  puts response["data"]
rescue APIVerve::Totpgenerator::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Totpgenerator::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "token": "935324",
    "digits": 6,
    "period": 30,
    "timeRemaining": 25,
    "expiresAt": "2025-12-16T22:31:00Z"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.