A simple WebSocket server that sends Bitcoin data to the client every 5 seconds.
Get from coibase.com:
API WebSocket connection.
- Bitcoin Price
Get from mempool.space:
API REST connection.
- Last block hegith
- Medium fee
-
Use the Node.js version specified in the
.nvmrc
file. (Install it if you don't have it installed yet.)nvm use
-
Install the dependencies.
pnpm install
-
Run the server.
pnpm dev
From your client, connect to the WebSocket server and send a message to subscribe it.
Subscribing message:
{ "action": "want" }
Responses:
-
Successfull message:
Subscribte to the WebSocket server!
-
Data every 5 seconds:
{ "lastBlock": <string>, "price": <string>, "mediumFee": <string> }