How To

How Hive Together gets the public Hive data it needs.

These examples focus on lookup options, not matching logic. Each method solves a different part of the data-access problem: indexed HTTP lookups, direct SQL-backed indexes, bounded account-history backfill, and targeted content resolution.

Hive Together also keeps a local SQLite cache of fetched history slices and result sessions. That cache avoids repeated external lookups, but the sources below are where the public chain data comes from.

Lookup Stack

hived HAF HAFBE HafSQL Hive RPC / REST fallback

Hive infrastructure is designed so HAF-backed services can answer many reads without every app running its own node. Hive Together cannot run hived or HAF on Heroku, so it starts with public HAFBE, uses public HafSQL by default when available, and then backfills with Hive RPC account history.

Hive Together also asks an unusual question: which public accounts interacted with each other? To answer that, it composes indexed lookups, account-history backfill, local SQLite cache, and app-side correlation.

HAFBE Indexed Lookups

hafbe

Ask HAF Block Explorer for indexed comment operations when available, and use block search as a candidate/fallback probe.

Solves

Speeds up comment, vote, and reward lookups by paging indexed author permlinks and then fetching operations for each permlink.

Advantages

HTTP-only, bounded, and useful as an accelerator without becoming a hard dependency.

Drawbacks

Public instances may vary by installed indexes; block-search can return only candidate blocks, so account-history RPC still verifies timeline coverage.

Author account whose indexed comment permlinks are paged.
Page of indexed permlinks to inspect.
Demo permlink page size is capped at 20.
Pick comment-family operation ids, or edit the comma-separated list directly.
Operations fetched for the first indexed permlink.
Ruby sample
require 'net/http'
require 'json'

base = 'https://api.hive.blog/hafbe-api'
permlinks_uri = URI("#{base}/accounts/"ned"/comment-permlinks")
permlinks_uri.query = URI.encode_www_form(
  'comment-type' => 'all',
  'page' => 1,
  'page-size' => 5
)

permlinks = JSON.parse(Net::HTTP.get(permlinks_uri))
permlink = permlinks.fetch('permlinks_result', []).first&.fetch('permlink')
abort 'No indexed permlinks on this page' unless permlink

ops_uri = URI("#{base}/accounts/"ned"/operations/comments/#{permlink}")
ops_uri.query = URI.encode_www_form(
  'operation-types' => "1,0,52,63",
  'page' => 1,
  'page-size' => 10,
  'direction' => 'desc'
)

operations = JSON.parse(Net::HTTP.get(ops_uri))
puts operations.fetch('operations_result', []).map { |row| row.dig('op', 'type') }
Try It result
Click “Try It” to run a bounded read-only lookup.

HafSQL Direct Lookup

hafsql

Query operation-specific PostgreSQL tables for indexed direct account edges.

Solves

Finds direct interactions quickly without first crawling account-history pages.

Advantages

Fast for supported operation families, good for cold result discovery, and naturally paginates by operation id.

Drawbacks

Requires configured PostgreSQL access, only covers irreversible/indexed data, and unsupported shapes still need RPC follow-up.

Vote table voter column.
Vote table author column.
Demo limit is capped at 20.
Ruby sample
require 'pg'

connection = PG.connect(ENV.fetch('HAFSQL_DATABASE_URL', 'postgres://hafsql_public:hafsql_public@hafsql-sql.mahdiyari.info:5432/haf_block_log'))
connection.exec('SET statement_timeout = 4000')
rows = connection.exec_params(<<~SQL, ["jerrybanfield", "luueetang", 5])
  SELECT id, voter, author, permlink
  FROM hafsql.operation_vote_view
  WHERE voter = $1 AND author = $2
  ORDER BY id DESC
  LIMIT $3
SQL

rows.each { |row| puts row.values_at('id', 'voter', 'author', 'permlink').join(' | ') }
Try It result
Click “Try It” to run a bounded read-only lookup.

Hive RPC Account History

hive_rpc

Scan bounded account-history pages from a public Hive API node.

Solves

Universal fallback for unsupported indexed shapes and timeline coverage verification.

Advantages

Works cold, needs no local index, supports operation bitmasks, and can backfill any account history.

Drawbacks

Dense accounts can take many pages, so Hive Together prefers indexed HAF/HAFBE/HafSQL lookups before using this path.

Hive account whose history will be scanned.
-1 asks the node for the newest page.
Demo limit is capped at 20.
Build a low-word bitmask from operation ids 0 through 63.
Ruby sample
require 'hive'

api = Hive::CondenserApi.new(url: 'https://api.hive.blog')
account = "ned"
start = -1
limit = 5
operation_filter_low = 2

api.get_account_history(account, start, limit, operation_filter_low, 0) do |history|
  history.reverse_each do |sequence, item|
    type, op = item.op
    puts [sequence, type, item.timestamp, op.author].compact.join(' | ')
  end
end
Try It result
Click “Try It” to run a bounded read-only lookup.

Comment Content Lookup

database_api.find_comments

Resolve known author/permlink targets into comment metadata and app-aware URLs.

Solves

Turns votes, reblogs, promotions, and reward virtual ops into useful click-through destinations.

Advantages

Small targeted lookup, returns metadata such as app tags, and falls back cleanly to a block explorer link.

Drawbacks

Requires knowing the author/permlink first and may not identify every front-end app.

Comment author account.
Comment or post permlink.
Ruby sample
require 'hive'
require 'json'

api = Hive::DatabaseApi.new(url: 'https://api.hive.blog')
target = {author: "luueetang", permlink: "the-streets-lights-have-been"}
response = api.find_comments(comments: [target])
comment = response.result.comments.first
metadata = JSON.parse(comment.json_metadata.presence || '{}')

puts metadata['app']
puts "https://hive.blog/@#{target[:author]}/#{target[:permlink]}"
Try It result
Click “Try It” to run a bounded read-only lookup.