Server-side client for the Affinity API. Requires Ruby 3.0+.
Version 0.3.0 targets the deployed Affinity API contract used by TypeScript SDK 1.16.0. Install this SDK from GitHub; registry publication is deferred.
git clone --branch v0.3.0 https://github.com/affinity-health/affinity-ruby.git
cd affinity-ruby
gem build Affinity.gemspec
gem install ./affinity-health-sdk-0.2.0.gemSet AFFINITY_API_KEY to a Test practice key on your server. Keep API keys out of browser and mobile code.
require "affinity"
api = Affinity::Client.new(ENV.fetch("AFFINITY_API_KEY"))
patients = api.patients.list({ limit: 20 })Practice keys identify their practice automatically. Platform keys pass a practice ID in request options or use a scoped client.
See the SDK guide for platform requests, patient updates, signing, submission, pagination, and errors. Routine patient writes generate an idempotency key. Persist your own keys for order creation, signing, and submission.
Defaults: API 2026-09-28, a 60-second timeout, and no automatic retries.
./scripts/check.shThe tests use synthetic fixtures on loopback. The fixture runner requires Python 3; Docker runs the language toolchain for the scripts/check.sh commands.
Generated with Cloudflare Forge, Fern, and Affinity's facade generator. generation.json records the pinned inputs. Fix the generator in the Affinity monorepo before regenerating client code.