From 0257b486e226eefe6d2e8631be5eb03394122d90 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Thu, 23 Apr 2026 15:39:49 -0400 Subject: [PATCH 1/9] docs: expand horizon streaming guide --- .../api-reference/structure/streaming.mdx | 64 ++++++++++++++----- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/docs/data/apis/horizon/api-reference/structure/streaming.mdx b/docs/data/apis/horizon/api-reference/structure/streaming.mdx index ad13f8ca33..00b71930f5 100644 --- a/docs/data/apis/horizon/api-reference/structure/streaming.mdx +++ b/docs/data/apis/horizon/api-reference/structure/streaming.mdx @@ -1,27 +1,59 @@ --- +id: streaming title: Streaming +description: Use Horizon streaming mode to receive new ledger data in near real time. Streaming requests use the same endpoint parameters as normal requests and can begin from the earliest known record or from a supplied cursor. +sidebar_label: Streaming sidebar_position: 30 --- -import { MethodTable } from "@site/src/components/MethodTable"; +Horizon supports streaming for endpoints that expose newly ingested ledger data over time. -Horizon provides a streaming mechanism for receiving events in near real time. Instead of repeatedly sending requests to Horizon for batch updates, a connection is established between a client and Horizon with updates to an endpoint response streaming as new ledgers close and updates occur. +Instead of repeatedly polling an endpoint for new results, you can keep a connection open and receive updates as new ledgers close and matching records become available. This is useful when you want to react to ledger activity without repeatedly issuing requests that return no new data. -This reduces requests that return no data and allows near instantaneous updates client-side. +## How Streaming Works -All attributes for the endpoints that allow streaming are the same as regular responses. A caller can initiate streaming by setting ‘Accept: text/event-stream’ in the HTTP header when making the request. +Streaming mode uses the same endpoint and query parameters as the standard request for that resource. - +To open a stream, send the request with the `Accept: text/event-stream` header. -| | -| ----------------------------------------------------- | -| [Ledgers](../resources/ledgers/README.mdx) | -| [Transactions](../resources/transactions/README.mdx) | -| [Operations](../resources/operations/README.mdx) | -| [Payments](../resources/payments/README.mdx) | -| [Effects](../resources/effects/README.mdx) | -| [Accounts](../resources/accounts/README.mdx) | -| [Trades](../resources/trades/README.mdx) | -| [Order Books](../aggregations/order-books/README.mdx) | +For example: - +```bash +curl -N \ + -H "Accept: text/event-stream" \ + "/operations?cursor=now" +``` + +## Cursor Behavior + +Cursor behavior is the main difference between a standard request and a streaming request. + +- If no `cursor` is provided, Horizon starts at the earliest known matching record and streams forward from there. +- If a `cursor` is provided, Horizon starts from that cursor. +- If `cursor=now` is provided, Horizon starts from your request time and streams only newly created matching records. + +Use `cursor=now` when you want to watch for new activity only. Use a specific cursor when you want to resume from a known point. + +## When To Use Streaming + +Streaming is a good fit when you want to: + +- watch for new transactions, operations, payments, or effects +- follow new ledger closures +- track changing order book data +- keep an application UI updated as new matching records arrive + +## Supported Endpoints + +Many Horizon resource endpoints support streaming. Check the individual endpoint reference to confirm whether a specific endpoint can be called in streaming mode. + +Common examples include endpoints for: + +- [Ledgers](../resources/ledgers/README.mdx) +- [Transactions](../resources/transactions/README.mdx) +- [Operations](../resources/operations/README.mdx) +- [Payments](../resources/payments/README.mdx) +- [Effects](../resources/effects/README.mdx) +- [Accounts](../resources/accounts/README.mdx) +- [Trades](../resources/trades/README.mdx) +- [Order Books](../aggregations/order-books/README.mdx) From 75d3521b28aeb23568a615ca459cbf842bbb2382 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Thu, 16 Apr 2026 04:47:02 -0400 Subject: [PATCH 2/9] Update pre-commit hook to check staged markdown files --- .husky/pre-commit | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 45f8b30339..653bb28f02 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,15 @@ G='\033[0;32m' P='\033[0;35m' CLEAN='\033[0;0m' -yarn run check:mdx || (echo -e "${G}Hint:${CLEAN} execute ${P}yarn run format:mdx${CLEAN} to format files" && exit 1) +staged_mdx_files=$(git diff --cached --name-only --diff-filter=ACMR -- '*.md' '*.mdx') + +[ -z "$staged_mdx_files" ] && exit 0 + +check_failed=0 + +printf '%s\n' "$staged_mdx_files" | xargs -n 50 yarn prettier --config .prettierrc.js -c || check_failed=1 + +[ "$check_failed" -eq 0 ] && exit 0 + +printf '%b\n' "${G}Hint:${CLEAN} execute ${P}yarn prettier --config .prettierrc.js --write ${CLEAN} to format the staged Markdown files" +exit 1 From 7835734d19499f09ef54976e0bfc6d4546b9ba28 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 04:12:10 -0400 Subject: [PATCH 3/9] Use refresh classic guides pre-commit hook --- .husky/pre-commit | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 653bb28f02..1f36600c02 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,16 +1,33 @@ +#!/bin/bash + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +if ! nvm use 22 >/dev/null 2>&1; then + echo "⚠️ Node v22 not installed. Skipping formatting check." + exit 0 +fi + G='\033[0;32m' P='\033[0;35m' CLEAN='\033[0;0m' -staged_mdx_files=$(git diff --cached --name-only --diff-filter=ACMR -- '*.md' '*.mdx') - -[ -z "$staged_mdx_files" ] && exit 0 - -check_failed=0 +if command -v yarn >/dev/null 2>&1; then + CHECK_OUTPUT=$(yarn run check:mdx 2>&1) + STATUS=$? -printf '%s\n' "$staged_mdx_files" | xargs -n 50 yarn prettier --config .prettierrc.js -c || check_failed=1 + if echo "$CHECK_OUTPUT" | grep -q 'The engine "node" is incompatible with this module'; then + echo -e "${G}Warning:${CLEAN} Node version mismatch. Skipping formatting check." + exit 0 + fi -[ "$check_failed" -eq 0 ] && exit 0 + if [ "$STATUS" -ne 0 ]; then + echo "$CHECK_OUTPUT" + echo -e "${G}Hint:${CLEAN} Run ${P}yarn run format:mdx${CLEAN} to fix formatting." + exit 1 + fi -printf '%b\n' "${G}Hint:${CLEAN} execute ${P}yarn prettier --config .prettierrc.js --write ${CLEAN} to format the staged Markdown files" -exit 1 +else + echo -e "${G}Hint:${CLEAN} Yarn not installed. Skipping formatting check." + exit 0 +fi \ No newline at end of file From c59aef294a0688e47de5eb4bc15094a95101bdbf Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 04:12:47 -0400 Subject: [PATCH 4/9] Update pre-commit hook to use Node 24 --- .husky/pre-commit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 1f36600c02..acac89bb41 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,8 +3,8 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -if ! nvm use 22 >/dev/null 2>&1; then - echo "⚠️ Node v22 not installed. Skipping formatting check." +if ! nvm use 24 >/dev/null 2>&1; then + echo "⚠️ Node v24 not installed. Skipping formatting check." exit 0 fi @@ -30,4 +30,4 @@ if command -v yarn >/dev/null 2>&1; then else echo -e "${G}Hint:${CLEAN} Yarn not installed. Skipping formatting check." exit 0 -fi \ No newline at end of file +fi From 10f992c9ec3f8da71839f79a187ea4855cb217c7 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 04:14:57 -0400 Subject: [PATCH 5/9] Revert "docs: expand horizon streaming guide" This reverts commit 0257b486e226eefe6d2e8631be5eb03394122d90. --- .../api-reference/structure/streaming.mdx | 64 +++++-------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/docs/data/apis/horizon/api-reference/structure/streaming.mdx b/docs/data/apis/horizon/api-reference/structure/streaming.mdx index 00b71930f5..ad13f8ca33 100644 --- a/docs/data/apis/horizon/api-reference/structure/streaming.mdx +++ b/docs/data/apis/horizon/api-reference/structure/streaming.mdx @@ -1,59 +1,27 @@ --- -id: streaming title: Streaming -description: Use Horizon streaming mode to receive new ledger data in near real time. Streaming requests use the same endpoint parameters as normal requests and can begin from the earliest known record or from a supplied cursor. -sidebar_label: Streaming sidebar_position: 30 --- -Horizon supports streaming for endpoints that expose newly ingested ledger data over time. +import { MethodTable } from "@site/src/components/MethodTable"; -Instead of repeatedly polling an endpoint for new results, you can keep a connection open and receive updates as new ledgers close and matching records become available. This is useful when you want to react to ledger activity without repeatedly issuing requests that return no new data. +Horizon provides a streaming mechanism for receiving events in near real time. Instead of repeatedly sending requests to Horizon for batch updates, a connection is established between a client and Horizon with updates to an endpoint response streaming as new ledgers close and updates occur. -## How Streaming Works +This reduces requests that return no data and allows near instantaneous updates client-side. -Streaming mode uses the same endpoint and query parameters as the standard request for that resource. +All attributes for the endpoints that allow streaming are the same as regular responses. A caller can initiate streaming by setting ‘Accept: text/event-stream’ in the HTTP header when making the request. -To open a stream, send the request with the `Accept: text/event-stream` header. + -For example: +| | +| ----------------------------------------------------- | +| [Ledgers](../resources/ledgers/README.mdx) | +| [Transactions](../resources/transactions/README.mdx) | +| [Operations](../resources/operations/README.mdx) | +| [Payments](../resources/payments/README.mdx) | +| [Effects](../resources/effects/README.mdx) | +| [Accounts](../resources/accounts/README.mdx) | +| [Trades](../resources/trades/README.mdx) | +| [Order Books](../aggregations/order-books/README.mdx) | -```bash -curl -N \ - -H "Accept: text/event-stream" \ - "/operations?cursor=now" -``` - -## Cursor Behavior - -Cursor behavior is the main difference between a standard request and a streaming request. - -- If no `cursor` is provided, Horizon starts at the earliest known matching record and streams forward from there. -- If a `cursor` is provided, Horizon starts from that cursor. -- If `cursor=now` is provided, Horizon starts from your request time and streams only newly created matching records. - -Use `cursor=now` when you want to watch for new activity only. Use a specific cursor when you want to resume from a known point. - -## When To Use Streaming - -Streaming is a good fit when you want to: - -- watch for new transactions, operations, payments, or effects -- follow new ledger closures -- track changing order book data -- keep an application UI updated as new matching records arrive - -## Supported Endpoints - -Many Horizon resource endpoints support streaming. Check the individual endpoint reference to confirm whether a specific endpoint can be called in streaming mode. - -Common examples include endpoints for: - -- [Ledgers](../resources/ledgers/README.mdx) -- [Transactions](../resources/transactions/README.mdx) -- [Operations](../resources/operations/README.mdx) -- [Payments](../resources/payments/README.mdx) -- [Effects](../resources/effects/README.mdx) -- [Accounts](../resources/accounts/README.mdx) -- [Trades](../resources/trades/README.mdx) -- [Order Books](../aggregations/order-books/README.mdx) + From 23fc6412913037093d9bd24f864150edc484769b Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 04:35:26 -0400 Subject: [PATCH 6/9] Handle non-nvm Node setups in pre-commit hook incl global v var --- .husky/pre-commit | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index acac89bb41..33ac1aea2b 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,23 @@ #!/bin/bash -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +REQ_NODE_MAJOR=$(sed -E 's/^v?([0-9]+).*/\1/' .nvmrc) -if ! nvm use 24 >/dev/null 2>&1; then - echo "⚠️ Node v24 not installed. Skipping formatting check." - exit 0 +if ! command -v node >/dev/null 2>&1 || [ "$(node -p 'process.versions.node.split(".")[0]')" -lt "$REQ_NODE_MAJOR" ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + + if command -v nvm >/dev/null 2>&1; then + if ! nvm use "$REQ_NODE_MAJOR" >/dev/null 2>&1; then + echo "Node v$REQ_NODE_MAJOR is not installed in nvm. Skipping formatting check." + exit 0 + fi + elif command -v node >/dev/null 2>&1; then + echo "Node v$REQ_NODE_MAJOR or higher is required, but $(node -v) is on PATH and nvm is not available. Skipping formatting check." + exit 0 + else + echo "Node is not installed and nvm is not available. Skipping formatting check." + exit 0 + fi fi G='\033[0;32m' From d839dcd702a692226309eb82ed2f7ecddd20534b Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 06:34:55 -0400 Subject: [PATCH 7/9] Review fixes pt2 (#26) * Handle non-nvm Node setups in pre-commit hook incl global v var * print consts up top * inline yarn presuming node * simplify prints --- .husky/pre-commit | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index acac89bb41..72db03b754 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,33 +1,30 @@ #!/bin/bash +REQ_NODE_MAJOR=$(sed -E 's/^v?([0-9]+).*/\1/' .nvmrc) -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +if ! command -v node >/dev/null 2>&1 || [ "$(node -p 'process.versions.node.split(".")[0]')" -lt "$REQ_NODE_MAJOR" ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -if ! nvm use 24 >/dev/null 2>&1; then - echo "⚠️ Node v24 not installed. Skipping formatting check." - exit 0 -fi - -G='\033[0;32m' -P='\033[0;35m' -CLEAN='\033[0;0m' - -if command -v yarn >/dev/null 2>&1; then - CHECK_OUTPUT=$(yarn run check:mdx 2>&1) - STATUS=$? - - if echo "$CHECK_OUTPUT" | grep -q 'The engine "node" is incompatible with this module'; then - echo -e "${G}Warning:${CLEAN} Node version mismatch. Skipping formatting check." + if command -v nvm >/dev/null 2>&1; then + if ! nvm use "$REQ_NODE_MAJOR" >/dev/null 2>&1; then + echo "❔ Node v$REQ_NODE_MAJOR is not installed in nvm. Skipping formatting check." + exit 0 + fi + elif command -v node >/dev/null 2>&1; then + echo "⚠ Node v$REQ_NODE_MAJOR or higher is required, but $(node -v) is on PATH and nvm is not available. Skipping formatting check." + exit 0 + else + echo "✖ Node is not installed and nvm is not available. Skipping formatting check." exit 0 fi +fi - if [ "$STATUS" -ne 0 ]; then - echo "$CHECK_OUTPUT" - echo -e "${G}Hint:${CLEAN} Run ${P}yarn run format:mdx${CLEAN} to fix formatting." +if command -v yarn >/dev/null 2>&1; then + if ! yarn run check:mdx; then + echo -e "ℹ Run \`yarn run format:mdx\` to fix formatting." exit 1 fi - else - echo -e "${G}Hint:${CLEAN} Yarn not installed. Skipping formatting check." + echo -e "❕ Yarn not installed. Skipping formatting check." exit 0 fi From 03920b2fea59d6bd1c5094bd0cdb75a62b5c57e8 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 06:56:57 -0400 Subject: [PATCH 8/9] org: check yarn before running --- .husky/pre-commit | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 72db03b754..188997723a 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,5 @@ #!/bin/bash + REQ_NODE_MAJOR=$(sed -E 's/^v?([0-9]+).*/\1/' .nvmrc) if ! command -v node >/dev/null 2>&1 || [ "$(node -p 'process.versions.node.split(".")[0]')" -lt "$REQ_NODE_MAJOR" ]; then @@ -19,12 +20,24 @@ if ! command -v node >/dev/null 2>&1 || [ "$(node -p 'process.versions.node.spli fi fi -if command -v yarn >/dev/null 2>&1; then - if ! yarn run check:mdx; then - echo -e "ℹ Run \`yarn run format:mdx\` to fix formatting." - exit 1 +if ! command -v yarn >/dev/null 2>&1; then + if command -v corepack >/dev/null 2>&1; then + if corepack enable >/dev/null 2>&1 && corepack prepare yarn@stable --activate >/dev/null 2>&1; then + echo "✓ Yarn is available through Corepack." + fi + fi + if ! command -v yarn >/dev/null 2>&1 && command -v npm >/dev/null 2>&1; then + if npm install -g yarn >/dev/null 2>&1; then + echo "✓ Yarn installed with npm." + fi fi -else - echo -e "❕ Yarn not installed. Skipping formatting check." - exit 0 + if ! command -v yarn >/dev/null 2>&1; then + echo "❕ Yarn not found. Skipping formatting check." + exit 0 + fi +fi + +if ! yarn run check:mdx; then + echo -e "ℹ Run \`yarn run format:mdx\` to fix formatting." + exit 1 fi From 8556bb7779edb37f2dbe6d4847787044bd0a6e86 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 26 Apr 2026 06:58:44 -0400 Subject: [PATCH 9/9] Use env bash for pre-commit hook Use #!/usr/bin/env bash so the hook finds Bash from the user's PATH across macOS, Linux, and Git Bash on Windows instead of assuming Bash lives at a fixed path like /bin/bash. --- .husky/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 188997723a..08803a44e9 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash REQ_NODE_MAJOR=$(sed -E 's/^v?([0-9]+).*/\1/' .nvmrc)