Skip to content

Add Stacks Blockchain API reference section#1845

Merged
wileyj merged 6 commits into
masterfrom
feat/stacks-blockchain-api-docs
Mar 20, 2026
Merged

Add Stacks Blockchain API reference section#1845
wileyj merged 6 commits into
masterfrom
feat/stacks-blockchain-api-docs

Conversation

@alexis-stacks
Copy link
Copy Markdown
Collaborator

@alexis-stacks alexis-stacks commented Mar 19, 2026

Summary

Adds the Stacks Blockchain API — the most widely used API for Stacks developers — to the Stacks.co reference section. This is the indexed REST API hosted by Hiro at api.hiro.so, which previously had no dedicated presence on Stacks.co despite being the primary API most developers interact with. Adding it here means the full reference spec is co-located alongside the Node RPC, Mesh, and Bridge APIs.

This PR was co-authored with Claude Code for the initial migration and conversion work. All content was manually reviewed, revised, and tested by @alexis-stacks prior to opening this PR — including a full manual pass in the GitBook live preview to confirm that all pages load, render correctly, and display as expected. The OpenAPI spec registration in GitBook was handled manually and confirmed working. Text revisions throughout were made collaboratively and approved before inclusion.

What's included

6 new prose pages under docs/reference/api/stacks-blockchain-api/:

  • README.md — Overview explaining what the API is, how it extends the Node RPC with indexed endpoints, Hiro branding, key features, and a quick curl example
  • usage.md — Base URL, making requests, API key authentication, and HTTP response codes
  • architecture.md — Architecture diagram, RPC proxy behavior, event observer pattern, PostgreSQL storage, and development setup
  • pagination.md — Limit/offset pagination pattern with sample JSON response
  • nonce-handling.md — Nonce endpoint usage and missing nonce detection
  • requesting-proofs.md — MARF Merkle Proof overview and the proof=0 parameter

Modified files:

  • SUMMARY.md — New section with 5 subpages + OpenAPI spec block referencing the existing stacks-blockchain-api-dereferenced spec already registered in GitBook
  • stacks-node-rpc/README.md — Added cross-link hint to the new Blockchain API section

Assets:

  • Architecture SVG diagram copied to .gitbook/assets/

Migration details

Source content was migrated from the Hiro docs repo and converted from MDX to GitBook markdown:

  • :::callout{% hint %} blocks
  • ```terminal / ```console -c```bash
  • <span className="font-bold">**bold**
  • Frontmatter stripped to description: only
  • Internal links converted to relative paths

Post-migration fixes

  • Fixed 3 broken external links (dead Rosetta API URL, dead BNS docs URL, stale blockstack/stacks-blockchain GitHub URL)
  • Fixed 1 broken repo-internal link (/docs/openapi.yaml → root-level openapi.yaml)
  • Corrected inaccurate claim that the API implements Rosetta/Mesh (it was removed; replaced by standalone Mesh API)
  • Fixed 4 typos carried from source ("the's", "return", "confirmation", "Merkel")
  • Fixed grammar and wording issues across multiple pages
  • Contextualized orphaned repo paths with GitHub links
  • Removed office hours references (no longer offered)
  • Normalized heading hierarchy and naming consistency across all pages
  • Added repo link to Development Setup section for context

alexis-stacks and others added 5 commits March 19, 2026 15:23
Migrate the Stacks Blockchain API prose documentation from the Hiro docs
repo (hiro-docs/content/docs/en/apis/stacks-blockchain-api/) into the
Stacks.co reference section. This is the indexed REST API hosted by Hiro
at api.hiro.so — the most-used API for Stacks developers — which
previously had no presence on Stacks.co.

What's added:
- 6 prose pages: overview, usage, architecture, pagination, nonce
  handling, and requesting proofs
- Architecture diagram SVG asset
- OpenAPI spec YAML block in SUMMARY.md referencing the spec slug
  "stacks-blockchain-api"
- Cross-link from the Stacks Node RPC README to the new section

The new section sits between "Stacks Node RPC" and "Stacks Mesh API" in
the reference sidebar, matching the existing API README patterns (hint
blocks, details/summary, OpenAPI spec link).

Source content was converted from Hiro's MDX format to GitBook markdown:
- :::callout → {% hint style="info" %}...{% endhint %}
- ```terminal / ```console -c → ```bash
- <span className="font-bold"> → **bold**
- Frontmatter stripped to description-only
- Internal links converted to relative paths

Manual steps required before this fully works:

1. Register the OpenAPI spec in GitBook. The YAML block in SUMMARY.md
   references `spec: stacks-blockchain-api`, which must be registered at
   the GitBook organization level. It cannot be created through Git
   alone. Options:
   a) GitBook CLI:
      npx @gitbook/cli@latest openapi publish \
        --spec stacks-blockchain-api \
        --organization <ORG_ID> \
        https://raw.githubusercontent.com/hirosystems/stacks-blockchain-api/master/openapi.yaml
   b) GitBook API (POST /v1/orgs/<ORG_ID>/openapi)
   c) GitBook web dashboard under the org's OpenAPI settings
   Once registered by URL, GitBook polls it every 6 hours for updates.

2. The spec may need dereferencing before upload if it contains $ref
   pointers that GitBook can't resolve. Hiro's build uses
   @apidevtools/swagger-parser for this. If GitBook rejects the raw
   YAML, dereference it first and upload the resolved JSON.

3. For ongoing maintenance, the CLI publish command can be added to a
   GitHub Action so the spec stays in sync when the upstream
   openapi.yaml changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Broken links (architecture.md):
- Replace dead rosetta-api.org URL with Mesh specifications GitHub repo
- Remove dead docs.stacks.co/clarity/example-contracts/bns link (404)
- Update blockstack/stacks-blockchain GitHub URL to canonical
  stacks-network/stacks-core (eliminates two-hop redirect chain)

Typos carried from Hiro source:
- nonce-handling.md: "the's" → "there's"
- pagination.md: "items return" → "items returned"
- requesting-proofs.md: "confirmation" → "confirmations"
- requesting-proofs.md: "Merkel" → "Merkle"

Orphaned repo paths (architecture.md):
- Convert bare /src/api/routes, /src/event-stream, /docs/openapi.yaml
  into clickable GitHub links to hirosystems/stacks-blockchain-api

README.md:
- Remove office hours / addevent.com references (no longer offered)
- Split combined warning hint into separate rate-limit warning and
  Discord support info hint

usage.md:
- Promote h3 subheadings (Base URL, Making requests, Authentication)
  to h2 to fix heading hierarchy (h1 → h2, not h1 → h3)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The file lives at the repo root (openapi.yaml), not under docs/.
The previous link to /blob/master/docs/openapi.yaml returned 404.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update the spec slug from `stacks-blockchain-api` to
`stacks-blockchain-api-dereferenced` to match the spec already
registered in GitBook (last updated ~2 months ago). This avoids
needing a new spec registration and lets us test the integration
immediately. Can be updated to the latest version if needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- README: rewrite intro to explain what the API is, how it extends
  Node RPC, who maintains it, and how it relates to other Stacks APIs
- usage: normalize "Stacks API" → "Stacks Blockchain API" for
  consistency across the section; fix "api-key" → "API key"
- architecture: correct inaccurate claim that the API implements
  Rosetta/Mesh (it was removed; replaced by standalone Mesh API);
  add repo link to Development Setup for context
- pagination: remove misleading empty object {} from sample JSON
- nonce-handling: fix grammar "For all transactions go through" →
  "For all transactions to go through"
- requesting-proofs: fix wording "endpoints will request the proof" →
  "endpoints return the proof"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexis-stacks alexis-stacks requested a review from wileyj March 19, 2026 23:46
@alexis-stacks alexis-stacks marked this pull request as ready for review March 19, 2026 23:46
Comment thread docs/reference/api/stacks-blockchain-api/nonce-handling.md Outdated
Comment thread docs/reference/api/stacks-blockchain-api/README.md
Copy link
Copy Markdown
Contributor

@wileyj wileyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm - one small nit about the testnet api link

Copy link
Copy Markdown

@rafa-stacks rafa-stacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments but overall LGTM! Thanks Alexis. We'll need to eventually update the architecture diagram, expand some of the text and also include the full API reference in this repo too, but this is a great initial PR

Comment thread docs/reference/api/stacks-blockchain-api/architecture.md Outdated
Comment thread docs/reference/api/stacks-blockchain-api/architecture.md Outdated
@wileyj
Copy link
Copy Markdown
Contributor

wileyj commented Mar 20, 2026

Just a couple comments but overall LGTM! Thanks Alexis. We'll need to eventually update the architecture diagram, expand some of the text and also include the full API reference in this repo too, but this is a great initial PR

I do think it's possible to render openapi yml directly - i'm pretty sure it's done that way for stacks-core openapi

- Use mainnet API URL with real principal in nonce example (wileyj)
- Remove "Express.js" from routes reference (rafa-stacks)
- Update stale docs link to docs.stacks.co (rafa-stacks)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@wileyj wileyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wileyj
Copy link
Copy Markdown
Contributor

wileyj commented Mar 20, 2026

good on my end - i'll defer to @rafa-stacks to verify, but i think ti's good to merge

@rafa-stacks
Copy link
Copy Markdown

I tried approving but I don't have repo write permissions so it won't let me. LGTM

@wileyj wileyj merged commit 386a20a into master Mar 20, 2026
19 checks passed
@wileyj wileyj deleted the feat/stacks-blockchain-api-docs branch March 20, 2026 20:17
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.

3 participants