PostHubify Ruby SDK

The official Ruby client for the PostHubify /v1 API — a single gem for social media publishing, inbox, contacts, analytics, ads, and telecom (SMS/OTP).

  • Zero runtime dependencies — Ruby standard library only (net/http).
  • Full surface — covers all 190+ operations of the /v1 spec one-to-one (verified by a contract test).
  • Ruby 2.6+

Installation

gem install posthubify

Quick start

require 'posthubify'

ph = Posthubify::Client.new(api_key: 'sk_...', base_url: 'https://api.posthubify.com/v1')

# Connection test
ph.ping  # => {"pong"=>true, "version"=>"v1", ...}

# Create a post
ph.posts.create({ 'content' => 'Hello world!', 'accountIds' => ['acc_1'] })

# Safe retry (Idempotency-Key — posts/sms/otp/ads/broadcasts)
require 'securerandom'
key = SecureRandom.uuid
ph.posts.create({ 'content' => 'Launch!', 'accountIds' => ['acc_1'] }, idempotency_key: key)

# Inbox analytics
ph.inbox_analytics.volume(from_date: '2026-06-01', to_date: '2026-06-14')

# Error handling
begin
  ph.posts.get('missing')
rescue Posthubify::Error => e
  puts [e.status, e.code, e.message].inspect  # [404, nil, "..."]
end

Resource groups

The exact same surface as the Node/Python SDKs, with snake_case accessors:

profiles · accounts · posts · media · tools · ads · insights · platform_analytics · inbox_analytics · inbox · comments · reviews · contacts · automations · broadcasts · sequences · webhooks · api_keys · queue (.schedules) · account_groups · engagement (.x) · users · invite_tokens · numbers · senders · sms · otp

Top level: ph.openapi, ph.ping, ph.me, ph.analytics, ph.analytics_posts, ph.analytics_timeseries, ph.logs, ph.usage.

Media upload

content = File.binread('logo.png')
asset = ph.media.upload(content, 'logo.png')  # => {"assetId"=>..., "url"=>...}
ph.posts.create({ 'content' => 'New!', 'accountIds' => ['acc_1'], 'mediaAssetId' => asset['assetId'] })

Development

ruby packages/ruby-sdk/test/test_contract.rb   # SDK ↔ spec contract test

The contract test verifies that the endpoint path produced by every SDK method is defined in the OpenAPI spec.

License

MIT