Vihaya SDK for Ruby โ Official vihaya-events Gem
vihaya-eventsis the official Ruby SDK for the Vihaya Events platform. Build event listings, attendee registration flows, Razorpay payment verification, ticketing dashboards, Rails apps, Sinatra apps, Hanami services, Sidekiq background jobs, and CLI tools โ all with idiomatic Ruby ergonomics and zero runtime dependencies.
Vihaya is the modern events platform for India โ a single stack for event organisers, ticketing, sponsor management, attendee registration, live check-in, and real-time analytics. This gem is the fastest way to integrate the Vihaya Events API (https://events.vihaya.app) into any Ruby 3.0+ codebase.
Table of contents
- What is Vihaya?
- Why the Vihaya Ruby SDK?
- The Vihaya SDK family
- Installation
- Get your Vihaya API key
- Quick start
- Configuration
- Core concepts
- Usage guide
- Framework integrations
- Mega events & sub-events
- Razorpay payment flow
- API reference
- Error handling
- Security best practices
- FAQ
- Keywords
- Development
- Contributing
- License
๐ฎ๐ณ What is Vihaya?
Vihaya is an all-in-one events platform for India, built for organisers who run college fests, hackathons, conferences, workshops, meetups, bootcamps, summits, and corporate events. The Vihaya platform provides:
- ๐๏ธ Event creation & ticketing with pricing tiers, promo codes, and a hosted checkout.
- ๐ข Mega events โ bundle dozens of sub-events under one parent fest.
- ๐ณ Razorpay payments โ end-to-end with server-side signature verification.
- ๐ Custom registration fields โ T-shirt size, college, team members, dietary preferences, accommodation.
- ๐ฅ Attendee management โ real-time registrations, broadcasts, CSV exports.
- ๐ฑ Live check-in with mobile QR scanning.
- ๐ฉโ๐ซ Speakers, agenda, sponsors, FAQs.
- ๐ Analytics โ registrations, revenue, funnel tracking.
This vihaya-events Ruby gem lets developers embed the Vihaya Events API into Rails apps, Sinatra microservices, Hanami projects, Sidekiq jobs, Jekyll plugins, Bridgetown sites, Pakyow apps, and any Ruby script.
Production URL: https://events.vihaya.app ยท Marketing site: https://vihaya.app ยท Developer dashboard: https://events.vihaya.app/profile/developer
โจ Why the Vihaya Ruby SDK?
-
๐ฆ Zero runtime dependencies โ built entirely on the Ruby standard library (
net/http+json). No Faraday, no HTTParty, no Typhoeus, no transitive dependency tree to audit. -
๐ Idiomatic Ruby โ snake_case everywhere, predicate methods (
event.mega_event?,sub.free?), keyword arguments, blocks-friendly. - ๐ช Tiny โ 10 tests, 44 assertions, runs in milliseconds against an in-process TCP stub server.
- ๐ Type-safe-ish โ every response is a typed value object with attribute readers.
- ๐งฉ Rails ready โ drop into a Rails initializer or Sidekiq worker without ceremony.
-
๐ก๏ธ MFA-protected โ
rubygems_mfa_required = trueso every release is two-factor authenticated. -
๐ณ Razorpay ready โ
vh.events.registerโ Razorpay โvh.payments.verify.
๐ The Vihaya SDK family (7 languages)
| Language | Package | Repository | Install |
|---|---|---|---|
| ๐ Ruby | vihaya-events |
Vishnu252005/vihaya-sdk-ruby | gem install vihaya-events |
| ๐จ JavaScript / TypeScript | vihaya-sdk |
Vishnu252005/vihaya-sdk | npm install vihaya-sdk |
| ๐ Python | vihaya-events |
Vishnu252005/vihaya-sdk-python | pip install vihaya-events |
| ๐ฆซ Go | vihaya-sdk-go |
Vishnu252005/vihaya-sdk-go | go get github.com/Vishnu252005/vihaya-sdk-go |
| โ Java | vihaya-sdk-java |
Vishnu252005/vihaya-sdk-java | JitPack / Gradle / Maven |
| ๐ PHP | vihaya/events |
Vishnu252005/vihaya-sdk-php | composer require vihaya/events |
| ๐ฑ Flutter / Dart | vihaya_sdk_flutter |
Vishnu252005/vihaya-sdk-flutter | flutter pub add vihaya_sdk_flutter |
All Vihaya SDKs target the same API base URL (https://events.vihaya.app), authenticate with the same x-api-key header, and expose the same methods.
๐ฆ Installation
Install the gem directly:
gem install vihaya-eventsOr add it to your Gemfile:
gem "vihaya-events"Then run:
bundle installRequirements:
- Ruby 3.0, 3.1, 3.2, 3.3, 3.4+
- No other dependencies โ pure stdlib
Gem name: vihaya-events. Require path: vihaya.
require "vihaya"๐ Get your Vihaya API key
- Sign up or log in at events.vihaya.app.
- Open the Developer Dashboard.
- Click Generate API Key and copy the
vh_live_...token. - Store it in
ENV["VIHAYA_API_KEY"], Rails credentials, or a secrets manager โ never commit it.
๐ Quick start
require "vihaya"
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
vh.events.list.each do |event|
puts "#{event.title} โ #{event.location} on #{event.date}"
endRegister an attendee
registration = Vihaya::RegisterData.new(
name: "Anjali Mehta",
email: "anjali@example.com",
phone: "+919820012345",
custom_fields: {
"T-Shirt Size" => "L",
"College" => "Vihaya Institute"
}
)
result = vh.events.register("evt_8x42j9", registration)
if result[:isPaid]
puts "Razorpay order: #{result[:orderId]}"
else
puts "Free registration: #{result[:registrationId]}"
endVerify a Razorpay payment
vh.payments.verify(
payment_id: "pay_O8K2...",
order_id: result[:orderId],
signature: "signature_from_razorpay"
)โ๏ธ Configuration
vh = Vihaya::Client.new(
ENV.fetch("VIHAYA_API_KEY"),
base_url: "https://events.vihaya.app", # override for staging
headers: { "X-Trace-Id" => "abc123" },
timeout: 60 # seconds
)| Option | Default | Description |
|---|---|---|
api_key (positional) |
โ | Required. Sent as x-api-key. |
base_url: |
https://events.vihaya.app |
API base URL. Override for staging. |
headers: |
{} |
Extra headers attached to every request. |
timeout: |
30 |
Per-request timeout in seconds. |
๐งญ Core concepts
- Events โ the root record. Title, description, date, venue, tiers, custom fields, speakers, agenda, sponsors, FAQs, sub-events.
-
Mega events โ parent events containing sub-events. Detect with
event.mega_event?, iterate viaevent.sub_events. - Registrations โ free or paid attendee entries with optional custom fields and team members.
-
Payments โ Razorpay orders created during
events.register, verified viapayments.verify. -
API key โ
vh_live_...token from the developer dashboard.
๐ Usage guide
Fetch a full event
event = vh.events.get("evt_8x42j9")
puts event.title
puts "Mode: #{event.event_mode} Timezone: #{event.timezone}"
puts "Location: #{event.location}"
puts "Date: #{event.date} #{event.time}"
event.speaker_list.each do |speaker|
puts "- #{speaker.name} (#{speaker.role}) @ #{speaker.company}"
end
event.agenda_list.each do |item|
puts "[#{item.time}] #{item.title}"
end
event.sponsors.each do |sponsor|
puts "#{sponsor.name} (#{sponsor.tier})"
end
event.faqs.each do |faq|
puts "Q: #{faq.question}\nA: #{faq.answer}\n\n"
end
event.special_prices.each do |tier|
puts " #{tier.name}: โน#{tier.amount}"
end
event.custom_fields.each do |field|
puts " #{field.name} [#{field.type}] required=#{field.required}"
endList & filter events
events = vh.events.list
upcoming = events.select { |e| Date.parse(e.date) > Date.today }
mega = events.select(&:mega_event?)
free = events.select(&:free?)
online = events.select { |e| e.event_mode == "online" }Register with tiers, promo codes, and custom fields
data = Vihaya::RegisterData.new(
name: "Priya Raj",
email: "priya@example.com",
phone: "+919820012345",
tier: "Early Bird",
promo_code: "LAUNCH10",
custom_fields: {
"College" => "IIT Bombay",
"T-Shirt Size" => "M",
"Year of Study" => "3rd"
}
)
vh.events.register("evt_conf_2026", data)Register a hackathon team
result = vh.events.register("evt_hackathon_2026",
name: "Team Lead",
email: "lead@example.com",
phone: "+919820012345",
teamName: "Byte Squad",
teamMembers: [
{ name: "Alice", email: "alice@example.com", phone: "+91..." },
{ name: "Bob", email: "bob@example.com", phone: "+91..." },
{ name: "Carol", email: "carol@example.com", phone: "+91..." }
]
)You can pass a plain Hash instead of RegisterData โ use camelCase keys for that path since the SDK sends it as-is.
๐จ Framework integrations
Rails โ initializer
# config/initializers/vihaya.rb
require "vihaya"
VIHAYA = Vihaya::Client.new(Rails.application.credentials.vihaya[:api_key])Rails โ controller
class EventsController < ApplicationController
def index
@events = VIHAYA.events.list
end
def show
@event = VIHAYA.events.get(params[:id])
rescue Vihaya::Error => e
redirect_to events_path, alert: e.message
end
def register
result = VIHAYA.events.register(
params[:id],
Vihaya::RegisterData.new(**registration_params)
)
render json: result
rescue Vihaya::Error => e
render json: { error: e.message }, status: e.status || 500
end
private
def registration_params
params.permit(:name, :email, :phone, custom_fields: {})
end
endSinatra
require "sinatra"
require "vihaya"
require "json"
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
get "/events" do
content_type :json
vh.events.list.map(&:to_h).to_json
end
post "/events/:id/register" do
content_type :json
data = JSON.parse(request.body.read, symbolize_names: true)
vh.events.register(params[:id], Vihaya::RegisterData.new(**data)).to_json
endSidekiq background job
class ProcessRegistrationJob
include Sidekiq::Job
def perform(event_id, payload)
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
vh.events.register(event_id, Vihaya::RegisterData.new(**payload.symbolize_keys))
end
endHanami action
module Web
module Actions
module Events
class Register < Web::Action
def handle(req, res)
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
result = vh.events.register(req.params[:id], req.params.to_h)
res.body = result.to_json
end
end
end
end
endStandalone CLI script
#!/usr/bin/env ruby
require "vihaya"
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
vh.events.list.each do |event|
puts "#{event.title.ljust(40)} #{event.date} #{event.location}"
end๐ข Mega events & sub-events
fest = vh.events.get("evt_mega_fest_2026")
if fest.mega_event?
puts "#{fest.title} โ #{fest.sub_events.size} sub-events"
fest.sub_events.each do |sub|
price = sub.free? ? "Free" : "โน#{sub.price}"
puts " - #{sub.title} (#{price})"
sub.custom_fields.each do |field|
puts " * #{field.name} [#{field.type}]"
end
end
endRegister for a specific sub-event:
vh.events.register("evt_sub_workshop_ml",
Vihaya::RegisterData.new(
name: "Rahul",
email: "rahul@example.com",
phone: "+91..."
)
)๐ณ Razorpay payment flow
-
Backend โ
vh.events.register(id, data)โ Vihaya creates a Razorpay order and returns:orderId. - Frontend โ launch Razorpay Checkout with that order ID.
-
Razorpay callback โ hands back
razorpay_payment_id,razorpay_order_id,razorpay_signature. -
Backend โ
vh.payments.verify(...)confirms the signature and marks the registration paid.
result = vh.events.register("evt_conf_2026",
Vihaya::RegisterData.new(
name: "Attendee",
email: "a@example.com",
phone: "+91..."
)
)
order_id = result[:orderId]
# Frontend: Razorpay Checkout with order_id ...
vh.payments.verify(
payment_id: razorpay_payment_id,
order_id: razorpay_order_id,
signature: razorpay_signature
)โ ๏ธ Always verify payments on the server. Never trust a signature checked only in the browser.
๐ API reference
Vihaya::Client.new(api_key, base_url: ..., headers: {}, timeout: 30)
The main client. api_key is required and positional; everything else is keyword.
vh.events
| Method | Returns | Description |
|---|---|---|
list |
Array<Vihaya::Event> |
All events on the authenticated account. |
get(event_id) |
Vihaya::Event |
Full metadata for one event โ tiers, custom fields, speakers, agenda, sponsors, FAQs, sub-events. |
register(event_id, data) |
Hash |
Submit a registration. data can be RegisterData or Hash. |
vh.payments
| Method | Returns | Description |
|---|---|---|
verify(payment_id:, order_id:, signature:, amount: nil) |
Hash |
Server-side Razorpay signature verification. |
Models (module Vihaya)
-
Vihaya::Eventโ root event with all metadata + predicate methods (mega_event?,free?,online?) -
Vihaya::Speaker,Vihaya::Sponsor,Vihaya::AgendaItem,Vihaya::FAQItem,Vihaya::Contact -
Vihaya::CustomField,Vihaya::SpecialPrice,Vihaya::PromoCode -
Vihaya::RegisterDataโ registration payload with keyword constructor -
Vihaya::Errorโ raised on every API failure
๐จ Error handling
All API failures raise Vihaya::Error with the HTTP status and raw body:
begin
vh.events.get("evt_does_not_exist")
rescue Vihaya::Error => e
puts "#{e.message} (status=#{e.status})"
puts e.data.inspect
case e.status
when 404 then puts "Not found"
when 401, 403 then puts "Auth error"
when 429 then puts "Rate limited"
end
end๐ก๏ธ Security best practices
Never hard-code a
vh_live_...key in code that ships to a client.
- Use
ENV, Rails encrypted credentials (Rails.application.credentials.vihaya),dotenv, or a secrets manager. - Call
events.registerandpayments.verifyfrom backend code only. - Always verify Razorpay signatures server-side.
- Rotate keys via the Vihaya developer dashboard if you suspect a leak.
- Use separate keys for staging and production.
โ FAQ
What is Vihaya?
Vihaya is an events platform for India โ ticketing, registrations, payments, check-in, analytics, and attendee management. Platform: vihaya.app. Dashboard: events.vihaya.app.
Why does the gem name differ from the require path?
You install with gem install vihaya-events but require with require "vihaya". The gem name reflects what it does on the platform; the require path is short and ergonomic.
Does the SDK support Faraday / HTTParty / Typhoeus?
No โ and that's intentional. Pure stdlib means no transitive dependencies, smaller install footprint, and no version conflicts with whatever HTTP library your Rails app already uses.
Does it work with Sidekiq, Resque, GoodJob?
Yes โ the client is just a Ruby object. Build it once at startup, share it across workers.
Does Vihaya support Razorpay test mode?
Yes โ use a test API key from the Vihaya developer dashboard.
Can I pass a plain Hash instead of RegisterData?
Yes. RegisterData is a convenience wrapper. A plain Hash works too โ just use camelCase keys (teamMembers, customFields, etc.) on that path.
๐ Keywords
vihaya ยท vihaya sdk ยท vihaya ruby ยท vihaya events ยท vihaya gem ยท vihaya-events ยท vihaya rails ยท vihaya sinatra ยท vihaya hanami ยท ruby events api ยท ruby ticketing gem ยท rails events sdk ยท ruby razorpay events ยท vihaya razorpay ruby ยท events api india ruby ยท event management gem ยท sidekiq vihaya ยท vihaya client ruby ยท rubygems vihaya ยท events.vihaya.app ruby ยท vihaya official ruby sdk
๐ ๏ธ Development
git clone https://github.com/Vishnu252005/vihaya-sdk-ruby.git
cd vihaya-sdk-ruby
ruby test/test_client.rb # Minitest suite (10 tests, 44 assertions)
gem build vihaya-events.gemspec # build the .gem fileThe test suite uses an in-process TCP stub server โ no Bundler, WebMock, or VCR required, no network calls.
Ruby version note: the gemspec requires Ruby โฅ 3.0. Use
/opt/homebrew/opt/ruby/bin/rubyon macOS โ system Ruby (/usr/bin/ruby2.6) is too old.
๐ค Contributing
Contributions to the Vihaya Ruby SDK are very welcome. The project is open source and MIT-licensed.
- Fork Vishnu252005/vihaya-sdk-ruby.
- Create a feature branch.
- Run
ruby test/test_client.rb. - Commit, push, and open a Pull Request.
Reporting issues
Found a bug or have a feature request? Open an issue at github.com/Vishnu252005/vihaya-sdk-ruby/issues.
๐ License
MIT ยฉ Vihaya. See LICENSE.
๐ฌ Support
- ๐ง Email: support@vihaya.app
- ๐ Website: vihaya.app
- ๐ ๏ธ Dashboard: events.vihaya.app
- ๐จโ๐ป Developer docs: events.vihaya.app/profile/developer/docs
- ๐ RubyGems: rubygems.org/gems/vihaya-events
- ๐ Issues: github.com/Vishnu252005/vihaya-sdk-ruby/issues
Built with โค๏ธ by the Vihaya team.
Related Vihaya SDK repositories
- Ruby: vihaya-sdk-ruby โ you are here
- JavaScript / TypeScript: vihaya-sdk
- Python: vihaya-sdk-python
- Go: vihaya-sdk-go
- Java: vihaya-sdk-java
- PHP: vihaya-sdk-php
- Flutter: vihaya-sdk-flutter