Use the abec JSON-RPC API to query blockchain data and manage node operations over HTTP POST or WebSockets.
1. Overview
abec provides a JSON-RPC API. There are some features in abec how RPCs are serviced:
- abec is secure by default which means that the RPC connection is TLS-enabled by default
- abec provides access to the API through both HTTP POST requests and Websockets
Websockets are the preferred transport for abec RPC and are used by applications such as abewallet for inter-process communication with abec. The websocket connection endpoint for abec is wss://your_ip_or_domain:8667/ws.
In addition to the standard API, an extension API is developping that is exclusive to clients using Websockets. In its current state, this API attempts to cover features found missing in the standard API
during the development of abewallet.
It should be pointed out that the current API list is not stable, while the standard API is designed as stable, the Websocket extension API should be considered a work in progress, incomplete, and susceptible to changes (both additions and removals).
2. HTTP POST Versus Websockets
The abec RPC server supports both HTTP POST requests and the preferred Websockets. All of the standard and extension methods described in this documentation can be accessed through both. As the name
indicates, the Websocket-specific extension methods can only be accessed when connected via Websockets.
As mentioned in the overview, the websocket connection endpoint for abec is wss://your_ip_or_domain:8667/ws.
The most important differences between the two transports as it pertains to the JSON-RPC API are:
3. Authentication
3.1 Authentication Overview
The following authentication details are needed before establishing a connection
to a abec RPC server:
-
rpcuser is the full-access username configured for the abec RPC server
-
rpcpass is the full-access password configured for the abec RPC server
-
rpclimituser is the limited username configured for the abec RPC server
-
rpclimitpass is the limited password configured for the abec RPC server
-
rpccert is the PEM-encoded X.509 certificate (public key) that the abec
server is configured with. It is automatically generated by abec and placed in the abec home directory (which is typically
%LOCALAPPDATA%\abed on Windows and ~/.abec on POSIX-like OSes)
NOTE: As mentioned above, abec is secure by default which means the RPC server is not running unless configured with a rpcuser and rpcpass and/or a rpclimituser and rpclimitpass, and uses TLS authentication for all connections.
Depending on which connection transaction you are using, you can choose one of two, mutually exclusive, methods.
- Use HTTP Authorization Header - HTTP POST requests and Websockets
- Use the JSON-RPC “authenticate” command - Websockets only
3.2 HTTP Basic Access Authentication
The abec RPC server uses HTTP basic access authentication with the rpcuser and rpcpass detailed above. If the supplied credentials are invalid, you
will be disconnected immediately upon making the connection.
3.3 JSON-RPC Authenticate Command (Websocket-specific)
While the HTTP basic access authentication method is the preferred method, the ability to set HTTP headers from websockets is not always available. In that case, you will need to use the authenticate JSON-RPC method.
The authenticate command must be the first command sent after connecting to the websocket. Sending any other commands before authenticating, supplying invalid credentials, or attempting to authenticate again when already authenticated will cause the websocket to be closed immediately.
4. Command-line Utility
abec comes with a separate utility named abectl which can be used to issue these RPC commands via HTTP POST requests to abec after configuring it with the information in the Authentication section above.
5. Standard Methods
5.1 Method Overview
The following is an overview of the RPC methods and their current status. Click the method name for further details such as parameter and return information.
5.2 Method Details
6. Example Code
This section provides example code for interacting with the JSON-RPC API in
various languages.
6.1 Go
This section provides examples of using the RPC interface using Go and the rpcclient package.
- Using getblockcount to Retrieve the Current Block Height
- Using getblock to Retrieve the Genesis Block
- Using notifyblocks to Receive blockconnected and blockdisconnected Notifications (Websocket-specific)
6.1.1 Using getblockcount to Retrieve the Current Block Height
The following is an example Go application which uses the rpcclient package to connect with a abec instance via Websockets, issues getblockcount to retrieve the current block height, and displays it.
Which results in:
6.1.2 Using getblock to Retrieve the Genesis Block
The following is an example Go application which uses the rpcclient package to connect with a abec instance via Websockets, issues getblock to retrieve information about the Genesis block, and display a few details about it.
Which results in:
6.1.3 Using notifyblocks to Receive blockconnected and blockdisconnected Notifications (Websocket-specific)
The following is an example Go application which uses the rpcclient package to connect with a abec instance via Websockets and registers for blockconnected and blockdisconnected notifications with notifyblocks. It also sets up handlers for the notifications.
Example output:
6.2. Example node.js Code
6.2.1 Using notifyblocks to be Notified of Block Connects and Disconnects
The following is example node.js code which uses ws (can be installed with npm install ws) to connect with a abec instance, issues notifyblocks to register for blockconnected and blockdisconnected notifications, and displays all incoming messages.
Last modified on November 11, 2026