Fragment Donor SDKSource

Version 0.1.3 · Registry installation commands use exact versions.

Ruby SDK for Telegram Stars and Premium

Install the independent Fragment Donor Ruby SDK, check usernames, gift Stars/Premium, and handle rate limits safely.

Purchase requests transmit your wallet mnemonic and Fragment session/cookie to the API operator.

Runtime: Ruby 3.2+. Version 0.1.3 is published; use the exact registry command shown on this page.

The client exposes username lookup, Stars purchase, Premium gift, and wallet balance with native naming for Ruby. Required request bodies use form-urlencoded. Wallet balances remain decimal strings; unknown response fields are retained.

Configure a request timeout and wallet credentials on your backend. Read retries are opt-in and bounded; purchase calls never retry automatically. Review the package README for the exact constructor and error classes.

Install

gem install fragment-donor-sdk -v 0.1.3

Example

require "fragment_donor_sdk"

client = FragmentDonor::Client.new(
  credentials: FragmentDonor::Credentials.new(
    mnemonic: ENV.fetch("FRAGMENT_MNEMONIC"),
    cookie: ENV.fetch("FRAGMENT_COOKIE"),
    wallet_version: "auto",
    provider_key: ENV["TONCONSOLE_API_KEY"] # optional provider key only
  ),
  connect_timeout: 5,
  request_timeout: 30
)
user = client.get_user_info("durov")
balance = client.wallet_balance
# Exact strings; do not convert to Float.
puts balance.ton

# Real-funds operations require both opt-in and one selected purchase.
if ENV["FRAGMENT_ALLOW_PURCHASES"] == "yes"
  begin
    case ENV["FRAGMENT_PURCHASE_KIND"]
    when "stars" then client.buy_stars("durov", 50, payment_method: "usdt_ton")
    when "premium" then client.buy_premium("durov", 3, payment_method: "ton")
    end
  rescue FragmentDonor::PurchaseOutcomeUnknownError => error
    # Reconcile error.details["tx_hash"] manually. Do not repeat the purchase.
  end
end

Source · ruby

Continue reading

Handle Telegram Stars API 429, Retry-After, and flood wait · Protect wallet credentials in API integrations · Fragment Donor API and SDK FAQ

OpenAPI 3.0 · Postman collection