The Stacks Blockchain API implements additional endpoints that provide data unavailable directly from Stacks nodes due to various constraints.
The stacks-node may not persist certain data or may not serve it efficiently to many clients. For instance, while it can return the current STX balance of an account, it cannot provide a history of account transactions.
The API implements the Rosetta specification by Coinbase, an open standard designed to simplify blockchain deployment and interaction. More information can be found at Rosetta API.
The API includes support for the Blockchain Naming System (BNS) endpoints. Details are available at BNS Documentation.
For Express.js routes, see the directory /src/api/routes.
The API creates an "event observer" http server which listens for events from a stacks-node "event emitter".
Events are HTTP POST requests containing:
Blocks
Transactions
Byproducts of executed transactions such as:
Asset transfers
Smart-contract log data
Execution cost data
The API processes and stores these events as relational data in PostgreSQL. For the "event observer" code, see /src/event-stream.
JSON Schemas are converted into TypeScript interfaces, which are used internally by the db controller module to transform SQL query results into the correct object shapes.
OpenAPI and JSON Schemas are also used to generate a standalone @stacks/blockchain-api-client.