The Stacks 2.0 Blockchain API allows you to query the Stacks 2.0 blockchain and interact with smart contracts. It was built to maintain pageable materialized views of the Stacks 2.0 Blockchain.
{% hint style="info" %} API Documentation Official API Documentation is available here. {% endhint %}
Note that the Stacks Node RPC API and the Hiro Stacks API are two different things. The Hiro API is a centralized service run by Hiro, a developer tooling company, that makes it easy to get onboarded and begin interacting with the Stacks blockchain in a RESTful way. You can also run your own API server
The Hiro Stacks API is a proxy for the Stacks Node API that makes it a bit easier to work with by providing additional functionality.
The RPC API is generated by every Stacks node and allows developers to self-host their own node and API for a more decentralized architecture.
{% hint style="info" %} This documentation only covers endpoints that are exposed on a Stacks node, referred to as the RPC API. For full documentation on the RESTful API, check out the Hiro's API reference. {% endhint %}
The RPC API can be used without any authorization. The basepath for the API is:
# for mainnet, replace `testnet` with `mainnet`
https://stacks-node-api.testnet.stacks.co/
The Stacks 2.0 Blockchain API (Hiro's API) is centrally hosted. However, every running Stacks node exposes an RPC API, which allows you to interact with the underlying blockchain. Instead of using a centrally hosted API, you can directly access the RPC API of a locally hosted Node.
While the Node RPC API doesn't give the same functionality as the hosted Stacks 2.0 Blockchain API, you get similar functionality in a way that is scoped to that specific node. The RPC API includes the following endpoints:
- POST /v2/transactions
- GET /v2/contracts/interface/{contract_address}/{contract_name}
- POST /v2/map_entry/{contract_address}/{contract_name}/{map_name}
- GET /v2/contracts/source/{contract_address}/{contract_name}
- GET /v2/accounts/{principal}
- POST /v2/contracts/call-read/{contract_address}/{contract_name}/{function_name}
- GET /v2/fees/transfer
- GET /v2/info
{% hint style="warning" %}
If you run a local node, it exposes an HTTP server on port 20443
. The info endpoint would be localhost:20443/v2/info
.
{% endhint %}