Motivation
Currently, (almost) all clients manually implement the Bitcoin Core RPC API, which leads to:
- Accidental implementation bugs (e.g., unit mistakes such as vB vs BTC/kvB)
- Difficulty maintaining clients as the API evolves
- Increased effort to implement clients in new programming languages
There is no formal, machine-readable specification of the RPC API. Existing documentation is not sufficient for code generation or type-safe client implementations. See discussion in #29912.
Overview
This PR introduces an initial OpenAPI/Swagger specification for the Bitcoin Core RPC and REST interfaces. The goal is to provide a foundation for:
- Automated client code generation in multiple languages (e.g., via Kiota)
- Easier maintenance and improved correctness for downstream clients
- A step towards a spec-driven development process for the RPC API
Details
- Adds
share/openapi.yml
describing the REST API (and/orbitcoin-rpc-openapi.yaml
for the JSON-RPC interface). - The spec is based on the current implementation and documentation, but is a work in progress and will need to be updated as the API evolves.
- See #29912 for background, rationale, and community discussion.
Tests
This change is documentation/specification only. No code is modified. Downstream client generators and tools can be used to validate the spec.
Further Work
- Extend the OpenAPI spec to cover all RPC methods and parameters, including type details and units.
- Consider generating JSON Schema or OpenRPC specifications for even better machine-readability and codegen support.
- Integrate with CI to ensure the spec remains up-to-date.
Closes #29912