Ruby client for Meta Threads Graph API; manages access tokens, fetches account data, paginates thread listings, and creates, publishes, or deletes text posts.
# Source: https://github.com/huginn/huginn | License: MIT | Copyright 2013, Andrew Cantino (Iteration Labs, LLC)
# Provided via justclaw.it.com; keep this notice with the code.
require "faraday"
class ThreadsApiClient
API_ROOT = "https://graph.threads.net/"
def initialize(access_token_provider:)
@access_token_provider = access_token_provider
end
def account(fields:)
connection.get("/v1.0/me", { fields: }.compact).body
end
def posts(user_id:, fields:, limit:, since: nil)
query = {
fields:,
limit:,
since:,
}.compact
posts = []
seen_cursors = {}
loop do
response = connection.get("/v1.0/#{user_id}/threads", query).body
page_posts, after = page_posts_and_after(response)
posts.concat(page_posts)
break unless
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key