Ampost Ruby SDK

By Published Updated

ampost is the official Ruby client for the Ampost API: one call publishes, schedules or drafts a post on every network you connect, using only net/http and json from the standard library.

Install

Ruby 3.1 or later, with no runtime dependencies. Or add gem "ampost" to your Gemfile.

terminal
gem install ampost

Publish a post

Create an API key in Setup → API keys, connect Bluesky and Threads in the dashboard, and put the key in AMPOST_API_KEY. Then:

post.rb
require "ampost"

client = Ampost::Client.new(api_key: ENV.fetch("AMPOST_API_KEY"))

post = client.posts.create({
  text: "Hello from the Ampost API 👋",
  targets: [{ platforms: ["bluesky", "threads"] }],
  publishNow: true
})
puts post["id"], post["status"]
post["platformPosts"].each { |p| puts "#{p["platform"]}: #{p["status"]}" }

What it does

  • Every endpoint, generated from the OpenAPI document, with YARD docs.
  • Request bodies are Hashes with the API's field names (publishNow, scheduledFor); responses are Hashes with string keys, as in the REST API reference.
  • Retries on 429 and 5xx with Retry-After, an automatic Idempotency-Key per call, and typed errors (Ampost::RateLimitError, Ampost::PermissionDeniedError, ...).
  • Pagination with each and a one-call media upload (client.media.upload("launch.mp4")).

Schedule or save a draft

Leave out publishNow for a draft, or set scheduledFor to a Time or an ISO 8601 string to schedule the post (paid plans):

schedule.rb
client.posts.create({
  text: "See you at the launch",
  targets: [{ platforms: ["bluesky"] }],
  scheduledFor: Time.utc(2026, 12, 1, 9) # or "2026-12-01T09:00:00Z"
})