Inplay_ai Ruby SDK
A thin, type-safe Ruby client for the InPlayAI event ingestion and metadata API.
Installation
Add this line to your application's Gemfile:
gem 'inplay_ai', path: 'sdk/ruby'
Or install it yourself as:
gem install inplay_ai
Usage
require 'inplay_ai'
# Use the singleton client for efficient connection reuse
client = InplayAi::Client.instance
# Send a wager event
client.wager({
wager_id: 'abc123',
user_id: 'user_456',
amount: 50.0,
payout: 92.0,
legs: [
{ market: '123:456:pregame', probability: 0.6, outcome: 'over', line: 26.5 },
{ market: '123:789:pregame', probability: 0.7, outcome: 'under', line: 28.0 }
],
timestamp: '2025-06-20T22:04:58Z'
})
# Send a settlement event
client.settlement({
wager_id: 'abc123',
amount: 92.0,
timestamp: '2025-06-20T22:04:58Z',
outcomes: [
{ market: '123:456:pregame', result: 'W' },
{ market: '123:789:pregame', result: 'L' }
]
})
# Upsert user metadata
client.user({
user_id: 'user_456',
first_name: 'John',
last_name: 'Doe'
})
# Upsert market metadata
client.market({
market_id: '123:456:pregame',
game: { id: 789, name: 'Lakers vs Celtics' },
team: { id: 5, name: 'Lakers' },
league: { id: 10, name: 'NBA' },
category: 'points'
})
Error Handling
If the API returns an error, the client will raise InplayAi::Error with the error response.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in lib/inplay_ai/version.rb, and then run bundle exec rake release.
License
The gem is available as open source under the terms of the MIT License.
API
All methods return a Promise and throw on API errors.
wager(data)— POST/v1/events/wagersettlement(data)— POST/v1/events/settlementuser(data)— POST/v1/metadata/usermarket(data)— POST/v1/metadata/markettarget(data)— POST/v1/metadata/targetevent(data)— POST/v1/metadata/event