Skip to content

feat(account): add GET /account/:id/offers endpoint with pagination#389

Open
JoshuaEdd wants to merge 1 commit into
stellarkit-lab-devtools:mainfrom
JoshuaEdd:feat/account-offers
Open

feat(account): add GET /account/:id/offers endpoint with pagination#389
JoshuaEdd wants to merge 1 commit into
stellarkit-lab-devtools:mainfrom
JoshuaEdd:feat/account-offers

Conversation

@JoshuaEdd

Copy link
Copy Markdown

Closes #273

Summary

Adds GET /account/:id/offers endpoint to retrieve all open offers for a Stellar account on the DEX.

What changed

  • src/routes/account.js — Rewrote /account/:id/offers handler:
    • Uses parsePaginationParams helper for limit, cursor, and order params
    • Normalises offer fields: offerId, selling, buying, price, amount, lastModifiedLedger
    • Returns data.offers array with total, limit, cursor metadata
    • Removed unused local validateLimit in favour of the shared one in validators.js
  • types/index.d.ts — Added OfferAsset, OfferData, AccountOffersResponse types
  • sdk/account.ts — Added typed getOffers() method with pagination options
  • sdk/stellarkit-client.js — Added getAccountOffers() method
  • tests/account.offers.test.js (new) — 7 mock-based tests covering success, empty, pagination, validation, and cursor
  • tests/api.test.js — Updated 5 existing integration tests for new response shape (data.offers / offer.offerId), added cursor + order tests

Key design decisions

  • Followed the existing paginated response pattern ({ offers, total, limit, cursor }) while renaming itemsoffers and idofferId as required
  • Reused parsePaginationParams from src/utils/pagination.js — already the standard pagination helper in the codebase
  • Added .order(order) chain call to the Horizon query since the parsePaginationParams helper validates this param
  • The local validateLimit duplicate was removed since it's no longer needed

Acceptance criteria checklist

  • Returns success: true and data.offers array
  • Supports limit and cursor query params
  • Uses parsePaginationParams helper
  • Normalised fields: offerId, selling, buying, price, amount, lastModifiedLedger
  • Tests cover success, empty, pagination, invalid ID, invalid limit, and cursor paths

Test output

PASS tests/account.offers.test.js (7/7)
PASS tests/account.notFound.test.js (1/1)
PASS tests/api.test.js — offers tests (5/5)
Lint: 0 errors, 21 pre-existing warnings

All 13 offers-related tests pass. No regressions. Pre-existing test failures in api.test.js (cache warming, CORS, asset verify, fee-estimate/trends) are unrelated to this change.

Follow-ups

  • The SDK could export the new OfferData type for external consumers
  • A WebSocket stream endpoint for live offer updates could be a future enhancement

Security note

All user-supplied input (accountId, limit, order, cursor) is validated server-side before reaching Horizon. No sensitive data is exposed or logged.

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@JoshuaEdd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Sulex45

Sulex45 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Kindly resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Endpoints | Add GET /account/:id/offers endpoint

2 participants