Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Account age and longevity metrics endpoint: `GET /account/:id/age`
- Asset freeze status check endpoint: `GET /account/:id/freeze-status/:assetCode/:assetIssuer`
- Liquidity pool positions endpoint: `GET /account/:id/pool-positions`
- Fee surge detection and recommendations endpoint: `GET /fee-estimate/surge-status`
- Fee trends analysis endpoint: `GET /fee-estimate/trends`
- DEX spread calculation endpoint: `GET /dex/spread/:sellAsset/:buyAsset`
- DEX order book imbalance detection endpoint: `GET /dex/imbalance/:sellAsset/:buyAsset`
- DEX arbitrage path discovery endpoint: `GET /dex/arbitrage/:assetCode/:assetIssuer`
- Claimable balance evaluation endpoint: `GET /claimable-balances/:id/evaluate/:accountId`
- Network ledger timing analysis endpoint: `GET /network/ledger-timing`
- Liquidity pool profitability endpoint: `GET /liquidity-pools/:id/profitability`
- Liquidity pool reserve ratio endpoint: `GET /liquidity-pools/:id/reserve-ratio`
- Account counterparties analysis endpoint: `GET /account/:id/counterparties`
- Transaction memo search endpoint: `GET /account/:id/transactions/search`
- Account inactivity status endpoint: `GET /account/:id/inactivity`
- Account subentry health endpoint: `GET /account/:id/subentry-health`
- Account sponsorship relationships endpoint: `GET /account/:id/sponsorship`
- Account can-receive asset check endpoint: `GET /account/:id/can-receive/:assetCode/:assetIssuer`
- Account offer history endpoint: `GET /account/:id/offer-history`
- Asset distribution and Gini coefficient endpoint: `GET /asset/:code/:issuer/distribution`
- Network validators endpoint: `GET /network/validators`

## [1.0.0] - 2026-05-27

### Added
Expand Down
69 changes: 61 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,40 @@ GET /asset/search?code=USDC

Establishes a live, real-time WebSocket connection to stream Stellar ledger updates. As new ledgers are closed on the Stellar blockchain, the API receives them via the Stellar Horizon SDK subscription, parses them, and immediately broadcasts them to connected WebSocket clients.

#### Client Connection Example (Vanilla JS)
#### Message Format

Each ledger update is broadcast as a JSON object containing:

```json
{
"sequence": 51234567,
"closedAt": "2026-05-26T20:15:00Z",
"baseFee": 100,
"transactionCount": 54
}
```

**Fields:**
- `sequence` — The ledger sequence number (incremental counter)
- `closedAt` — ISO 8601 timestamp when the ledger closed
- `baseFee` — Base fee in stroops for transactions in this ledger
- `transactionCount` — Number of successful transactions in this ledger

#### CLI Example (wscat)

Install wscat globally if you don't have it:
```bash
npm install -g wscat
```

Connect to the ledger stream:
```bash
wscat -c ws://localhost:3000/stream/ledgers
```

You'll immediately start receiving live ledger updates as they close on the network.

#### Browser WebSocket API Example

```javascript
const ws = new WebSocket("ws://localhost:3000/stream/ledgers");
Expand All @@ -1578,13 +1611,8 @@ ws.onopen = () => {
ws.onmessage = (event) => {
const ledger = JSON.parse(event.data);
console.log("New ledger closed:", ledger);
// Example output:
// {
// "sequence": 51234567,
// "closedAt": "2026-05-26T20:15:00Z",
// "baseFee": 100,
// "transactionCount": 54
// }
console.log(`Ledger ${ledger.sequence} closed at ${ledger.closedAt}`);
console.log(`Transactions: ${ledger.transactionCount}, Base Fee: ${ledger.baseFee} stroops`);
};

ws.onerror = (error) => {
Expand All @@ -1596,6 +1624,31 @@ ws.onclose = () => {
};
```

#### Node.js Example

```javascript
const WebSocket = require("ws");

const ws = new WebSocket("ws://localhost:3000/stream/ledgers");

ws.on("open", () => {
console.log("Connected to StellarKit ledger stream!");
});

ws.on("message", (data) => {
const ledger = JSON.parse(data.toString());
console.log("New ledger:", ledger);
});

ws.on("error", (error) => {
console.error("WebSocket error:", error);
});

ws.on("close", () => {
console.log("Connection closed");
});
```

---

## Development
Expand Down
Loading