Skip to content

Provide code examples to make http requests using Stellar SDK in docs #404

Open

Description

@janewang

What problem does your feature solve?

Missing examples on using the SDK

What would you like to see?

For RPC documentation and Horizon documentation: we could switch all our Javascript and Python code examples to make http requests using a Stellar SDK (as opposed to general http libs like requests) and show encoding/decoding of XDR (as opposed to using opaque b64 strings)

What alternatives are there?

Activity

  1. moved this from Backlog to To Do in Dev Docson Jun 5, 2024
  2. ElliotFriend commented on Jun 20, 2024

    @ElliotFriend
    Contributor

    For Horizon, this is much more easily done. I recently learned about the x-codeSamples openapi extension, and it will enable us to bake that right into the API specfile, to be generated at build/deploy time.

    I don't think there is an openrpc equivelant to this, though. So, for RPC we might be out of luck for now

  3. chadoh commented on Aug 2, 2024

    @chadoh
    Contributor

    @janewang @ElliotFriend I created #860 to make it easier to maintain our own fork of the open-rpc-docs-react package, which is how we add those tabs to show various ways of doing the RPC calls. However, my fork does not modify the tabs or examples yet.

    I'm not sure we should remove the plain-JS fetch-style examples. Seems kinda nice to show how simple it is. Maybe we could add a JS SDK tab in addition?

    And as for Python—I've never used this. I guess lots of Stellar developers must? Maybe we could add another tab for Python SDK also.

  4. moved this from To Do to In Progress in Dev Docson Aug 2, 2024
  5. janewang commented on Aug 6, 2024

    @janewang
    ContributorAuthor

    We are going publish the npm package

  6. janewang commented on Aug 13, 2024

    @janewang
    ContributorAuthor

    Need to publish the npm package

  7. added and removed
    good first issue
    on Jan 7, 2025
  8. moved this from In Progress to To Do in Dev Docson Jan 7, 2025
  9. removed their assignment
    on Mar 4, 2025
  10. sreuland commented on Mar 11, 2025

    @sreuland
    Contributor

    Considering the large amount of content across the API docs:

    The permutations over each language example expressed as SDK usage(python, js, go) per each endpoint will be a considerable effort to manually copy code samples(which should be tested) as stubs into the docs repo per each language per each endpoint. This increases the amount of maintenance to keep each SDK code sample up to date going forward related to protocol updates or sdk blasts.

    Before getting deeper into the solution for achieving this, another thought which may be considered more decentralized - Can we defer to each SDK to generate its own docs and examples? Has this already been considered and/or ruled out?

  11. self-assigned this
    on Mar 11, 2025
  12. mollykarcher commented on Mar 12, 2025

    @mollykarcher
    Contributor

    @sreuland there's some related discussion on this as well over on this issue - #441 (comment)

  13. added
    documentation
    on Jul 13, 2026
  14. ElliotFriend commented on Jul 13, 2026

    @ElliotFriend
    Contributor

    Hi @sreuland 👋 I'm doing a triage pass over our open issues, and this one hasn't seen activity in a while. Two quick questions:

    • Is this still relevant / still on your radar?
    • Is there anything you need to move it forward — review, context, a decision, someone to pair with?

    If it's no longer on your plate, no worries at all — just say the word and we'll open it up for other contributors. If I don't hear back in a couple weeks, I'll free up the assignment so it doesn't look claimed.

  15. kaankacar commented on Sep 7, 2026

    @kaankacar
    Contributor

    Triage bot is looking at this issue.

    I am checking the live docs and the build setup. I will report back.

  16. kaankacar commented on Sep 7, 2026

    @kaankacar
    Contributor

    Triage bot report. This issue needs a maintainer decision.

    Decision needed: does stellar-docs own SDK code examples for every API reference endpoint, or does each SDK own its own examples?

    Options

    1. Docs repo owns them. Add SDK examples for all Horizon and RPC endpoints. Highest maintenance cost.
    2. Each SDK owns them. Close this issue and link out to the SDK docs. This is @sreuland's suggestion.
    3. Split. Generate the RPC tabs once in the shared component. Hand-write Horizon samples for the busiest endpoints only.

    Horizon: the mechanism already works

    • x-codeSamples is live. See openapi/horizon/components/endpoints/feeStats.yml:19.
    • Only 5 of 47 operations use it. 5 carry JavaScript. 2 carry Python.
    • Every spec change also needs pnpm api and a commit of the generated pages.

    RPC: the 2024 blocker is gone

    • The cURL, JavaScript fetch and Python requests tabs are hardcoded in @stellar/open-rpc-docs-react, at src/ExamplePairing/ExamplePairing.tsx:62-83.
    • The OpenRPC spec cannot add tabs. Nothing in that package reads a code-samples field.
    • SDF now owns that package. One change there gives SDK tabs on all 12 method pages at once. @ElliotFriend, this removes the constraint you named in 2024.
    • Today only 3 of 12 method pages carry hand-written SDK examples.

    Two smaller choices inside option 1 or 3

    • Replace the plain HTTP examples, or keep them and add an SDK tab? The issue says replace. @chadoh asked to keep them.
    • Which languages: JavaScript, Python, Go?

    Related: #441 asks the same question for RPC and is also open. Please settle both together.

    Separate small defect I found: openapi/horizon/components/endpoints/paths.yml:42 installs the deprecated stellar-sdk package, while its own label says @stellar/stellar-sdk. I can send that one-line fix as its own PR on request.

    @kaankacar @ElliotFriend

  17. added
    bot:needs-decision
    on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot:needs-decisiondocumentationplatform

    Type

    No type

    Projects

    • Status
      To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions