Skip to content

feat: add GET /v0/blockInfo/{blockHash} endpoint#170

Merged
DOBEN merged 1 commit intoConcordium:mainfrom
lysyi3m:feature/add-block-info-endpoint
Mar 10, 2026
Merged

feat: add GET /v0/blockInfo/{blockHash} endpoint#170
DOBEN merged 1 commit intoConcordium:mainfrom
lysyi3m:feature/add-block-info-endpoint

Conversation

@lysyi3m
Copy link
Copy Markdown
Contributor

@lysyi3m lysyi3m commented Mar 6, 2026

Purpose

Adds a new GET /v0/blockInfo/{blockHash} endpoint that returns metadata for a block identified by its hash.

Motivation

Following up on #169 — wallet clients that need to query chain history currently require a direct gRPC connection to the node. A blockInfo endpoint through the proxy allows fetching block metadata (height, baker, transaction count, timestamps, finalization status) via REST, without a gRPC client.

Changes

  • src/Proxy.hs: New route /v0/blockInfo/#Text BlockInfoR GET and handler (~15 lines)
  • src/Internationalization/Base.hs: New EMMalformedBlockHash error constructor
  • src/Internationalization/En.hs: English translation for the new error
  • ChangeLog.md: Entry under [unreleased]
  • README.md: Endpoint listed + full response format documentation

Implementation

Parses the block hash from the path using readMaybe, calls getBlockInfo (Given blockHash), and returns the result directly as JSON. The BlockInfo type already has a ToJSON instance via deriveJSON, so no manual field mapping is needed. Returns 404 if the block hash is not found, 400 if the hash is malformed.

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0

@lysyi3m
Copy link
Copy Markdown
Contributor Author

lysyi3m commented Mar 6, 2026

@td202 hey! 👋🏻 as a follow up for #169, here I have another endpoint suggestion. Let me know if you think it needs to be updated.

Thanks in advance! 🍻

@DOBEN DOBEN added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Mar 9, 2026
Copy link
Copy Markdown
Member

@DOBEN DOBEN left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @lysyi3m! It looks good.

  Add a new endpoint that returns block information for a given block hash.
  The response uses the existing BlockInfo type which already has a ToJSON
  instance, so the full block metadata is returned directly.

  Returns 404 if no block with the given hash exists.
  Returns 400 if the provided hash is malformed.
@lysyi3m lysyi3m force-pushed the feature/add-block-info-endpoint branch from 28d5c33 to 0c2e604 Compare March 10, 2026 07:46
@lysyi3m lysyi3m requested a review from DOBEN March 10, 2026 07:49
@DOBEN DOBEN merged commit 7199775 into Concordium:main Mar 10, 2026
2 checks passed
@lysyi3m lysyi3m deleted the feature/add-block-info-endpoint branch March 10, 2026 13:08
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.

2 participants