Vihaya Events — Ruby SDK
The official Ruby SDK for the Vihaya Events platform.
Built on the Ruby standard library (net/http + json) with zero runtime
dependencies, and feature parity with the JavaScript, Flutter, and Python
SDKs.
Install
gem install vihaya-eventsOr add it to your Gemfile:
gem "vihaya-events"Requires Ruby 3.0+.
Quick start
require "vihaya"
vh = Vihaya::Client.new("vh_live_...") # get your key from the developer dashboard
vh.events.list.each do |event|
puts "#{event.title} — #{event.location}"
endFetch a full event
events.get returns an Event with every piece of metadata the organizer
has configured — speakers, agenda, sponsors, FAQs, custom fields, pricing
tiers, and sub-events for mega events.
event = vh.events.get("evt_8x42j9")
puts event.title
puts "Mode: #{event.event_mode} Timezone: #{event.timezone}"
event.speaker_list.each do |speaker|
puts "- #{speaker.name} (#{speaker.role})"
end
event.agenda_list.each do |item|
puts "[#{item.time}] #{item.title}"
end
event.special_prices.each do |tier|
puts " #{tier.name}: ₹#{tier.amount}"
endMega events
If event.mega_event? is true, it contains sub-events. Each sub-event has
its own tiers, custom fields, etc.
if event.mega_event?
event.sub_events.each do |sub|
price = sub.free? ? "Free" : "₹#{sub.price}"
puts "- #{sub.title} (#{price})"
end
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]
order_id = result[:orderId]
# Launch Razorpay checkout with this order_id, then verify server-side:
vh.payments.verify(
payment_id: "pay_xxx",
order_id: order_id,
signature: "sig_xxx"
)
else
puts "Registered! ID: #{result[:registrationId]}"
endYou can also pass a plain Hash instead of RegisterData if you prefer — the
SDK will send it as-is, so use camelCase keys for that path.
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
endAPI reference
Vihaya::Client.new(api_key, base_url: ..., headers: {}, timeout: 30)
The main client. api_key is required; 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. |
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. |
Security: never hard-code a live secret key in client-side code. Use environment variables and perform payment verification from a trusted backend environment only.
Development
git clone https://github.com/Vishnu252005/vihaya-sdk-ruby.git
cd vihaya-sdk-ruby
ruby test/test_client.rb
gem build vihaya-events.gemspecLicense
MIT — see LICENSE.