You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document the response differences between Horizon and RPC - #2828
Refs #1621. The migration guide maps each Horizon endpoint to an RPC method, but it never said the two responses have different shapes. This adds a Response Differences section that compares GET /accounts/{address} with getLedgerEntries side by side, using real Testnet responses, and covers response shape, raw stroop amounts, XDR encoding, the flags and thresholds fields, and the missing-entry case. It also links the migration guide from the APIs overview, which had no inbound link to it.
This uses "Refs", not "Closes". The issue asks for a comparison of the most-used Horizon endpoints, and this delivers the account endpoint only. Please close the issue when the remaining endpoints are covered.
Verified against live Testnet data and primary sources:
Horizon 9009.2998203 XLM equals the account entry's 90092998203 stroops. Horizon 1252.7872975 USDC equals the trustline entry's 12527872975.
AccountEntry in stellar-xdr v28.0 has no trustline field and comments int64 balance as "in stroops".
The XDR comment on thresholds reads [weight of master|low|medium|high], which matches the live "01000000" next to Horizon's master key signer of weight 1.
TrustLineFlags sets AUTHORIZED_FLAG = 1, which matches the live flags: 1 and Horizon's is_authorized.
The openrpc spec sets the 200-key limit and warns that the xdrFormat: "json" shape is not stable.
A key for an account that does not exist returns HTTP 200 with that key absent from entries. Horizon returns 404 for the same account.
The migration guide maps each Horizon endpoint to an RPC method, but it
never said that the two responses have different shapes. That gap is the
one people hit first: Horizon aggregates an account with its trustlines
and formats amounts to seven decimal places, while getLedgerEntries
returns one raw ledger entry per key with amounts as int64 stroops.
Add a Response Differences section that compares GET /accounts/{address}
with getLedgerEntries side by side, using real Testnet responses. It
covers response shape, raw amounts, XDR encoding, the flags and
thresholds fields, and the fact that a missing entry is a 200 rather
than a 404.
Also link the migration guide from the APIs overview, which had no
inbound link to it.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds documentation to help developers migrating from Horizon to RPC understand and handle the different response shapes—specifically by introducing a side-by-side “Response Differences” section in the migration guide and adding an inbound link from the APIs overview.
Changes:
Add an inbound link from the APIs overview to the Horizon→RPC migration guide.
Add a “Response Differences” section comparing Horizon GET /accounts/{address} to RPC getLedgerEntries, including worked example responses and guidance on amounts, encoding, flags/thresholds, and missing-entry behavior.
Update the endpoint mapping row for GET /accounts/{address} to point readers to the new example section.
Recommendation: NEEDS-CHANGES — the RPC example response should include entry keys (to support the “missing entry” guidance), and the new XDR reference should be consistent with the rest of the RPC docs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File
Description
docs/data/apis/README.mdx
Adds a direct link to the migration guide from the APIs overview.
docs/data/apis/migrate-from-horizon-to-rpc.mdx
Adds a new “Response Differences” section and links it from the endpoint mapping table.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
docs/data/apis/migrate-from-horizon-to-rpc.mdx:24
The table says RPC returns a “Signed 64-bit integer”, but in JSON responses these int64 values are typically serialized as strings (as shown in the example snippet). Clarifying this avoids suggesting callers can safely treat the value as a JSON number.
This issue also appears on line 162 of the same file. docs/data/apis/migrate-from-horizon-to-rpc.mdx:195
This row uses “trust line” but the docs elsewhere (including this page’s earlier “trustline entries”) consistently use “trustline” as a single term. Aligning terminology will reduce confusion for readers searching the docs.
“RPC returns the integer itself” is a bit misleading in the xdrFormat: "json" context, since int64 amounts are usually returned as JSON strings to preserve precision. Tweaking the wording here will align with the example response and the big-number advice.
Every classic amount on the ledger is a signed 64-bit integer of stroops. Horizon divides it by ten million and returns a string with seven decimal places. RPC returns the integer itself. Divide it in your own code, and use a big-number type so you do not lose precision. See [Amount precision](../../learn/fundamentals/stellar-data-structures/assets.mdx#amount-precision).
🤖 Automated message from Kaan's Automated Triage Bot.
Round 2 had no active comments. Three suppressed comments, all accepted and fixed in 5e0dd14.
int64 amounts: correct. A live Testnet call returns "balance": "90092998203", a JSON string. The table now says "sent as a string". The Amounts section now says the value is a JSON string, not a JSON number.
"trust line" in the mapping table: correct. 88 docs files use "trustline", 11 use "trust line". Changed to "trustline".
This section describes missing keys as being "left out of entries", but per the RPC OpenRPC schema entries itself may be omitted when no entries are found. Mentioning this avoids clients assuming entries is always an array.
### A Missing Entry Is Not an Error
Horizon answers `404` when a resource does not exist. RPC answers `200` and leaves the key out of `entries`, so a request for two keys can return one entry. Match each returned entry back to its own key with the entry's `keyJson` field, or `key` in the default base64 format. Do not match on the position you sent it in.
The server always sends entries, as an empty array when nothing is
found, while the OpenRPC specification lists only latestLedger as
required. Say both so clients handle either.
Copilot's last two passes pulled in opposite directions on entries: one said the optional-field claim is stale because the server always sends it, the next said to align with the OpenRPC contract, which lists only latestLedger as required. Both facts are true, so aa22e46 states both: the current server always sends entries, as an empty array when nothing is found, and clients should still treat a missing field as empty because the specification does not require it.
Horizon sets an account's paging_token to its account ID (resourceadapter/account_entry.go: dest.PT = account.AccountID), and the live Testnet response returns it that way. The row's point stands: the account endpoint is one resource with no paging.
XLM is included in Horizon's balances, but it has no trustline; its balance comes from the account entry. Qualify this as one trustline key per non-native balance (including pool-share balances) so readers do not try to construct a trustline key for native XLM.
The native balance lives in the account entry, so only non-native balances need a trustline key. Liquidity pool shares do have trustlines (TrustLineAsset carries ASSET_TYPE_POOL_SHARE), so they count.
Back on this because new commits and Copilot reviews arrived on a PR I reviewed before.
I pushed two fixes for Copilot's suppressed notes:
e15bb49 drops "its paging_token is empty". Live Horizon sets paging_token to the account ID.
fc88eea says XLM needs no trustline key, and pool shares do (TrustLineAsset has ASSET_TYPE_POOL_SHARE).
Verified: the example values still match live Testnet, all checks are green, and Copilot's last round has no findings. No live preview was available, so this relies on the green build / build. The section now sits after the endpoint table, as @ElliotFriend asked. Ready to merge.
Adds the Response Differences section and its Account Balances
example, the pointer to it in the intro, the trustline wording and
link in the accounts row, and the AccountEntry reference. The APIs
landing page links to the migration guide from its Horizon warning,
root-relative. Applied hunk by hand because the export's link style
made the three-way merge conflict on unrelated lines.
Checks: parity all upstream lines present (7 differ only by link and
admonition conversion), guard clean, mint validate passed,
broken-links at baseline 8, both pages 200.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bot:ready-to-mergeBot verified and approved; waiting for a maintainer to merge
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Automated triage bot, acting for @kaankacar.
Refs #1621. The migration guide maps each Horizon endpoint to an RPC method, but it never said the two responses have different shapes. This adds a Response Differences section that compares
GET /accounts/{address}withgetLedgerEntriesside by side, using real Testnet responses, and covers response shape, raw stroop amounts, XDR encoding, the flags and thresholds fields, and the missing-entry case. It also links the migration guide from the APIs overview, which had no inbound link to it.This uses "Refs", not "Closes". The issue asks for a comparison of the most-used Horizon endpoints, and this delivers the account endpoint only. Please close the issue when the remaining endpoints are covered.
Verified against live Testnet data and primary sources:
9009.2998203XLM equals the account entry's90092998203stroops. Horizon1252.7872975USDC equals the trustline entry's12527872975.AccountEntryin stellar-xdr v28.0 has no trustline field and commentsint64 balanceas "in stroops".thresholdsreads[weight of master|low|medium|high], which matches the live"01000000"next to Horizon's master key signer of weight 1.TrustLineFlagssetsAUTHORIZED_FLAG = 1, which matches the liveflags: 1and Horizon'sis_authorized.xdrFormat: "json"shape is not stable.entries. Horizon returns 404 for the same account.