A step-by-step guide to connecting to the CoinPaprika Streaming API and receiving live ticker data in less than 5 minutes.
ws
library for handling WebSockets in Node.js.
mkdir coinpaprika-5min-stream
cd coinpaprika-5min-stream
package.json
file for your project.npm init -y
ws
library to handle the WebSocket connection.npm install ws
package.json
file and add "type": "module"
:{
"name": "coinpaprika-5min-stream",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"ws": "^8.14.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
index.js
in your project folder. This file will contain all the code for our streaming client.
Open index.js
and paste the following code into it. Be sure to replace "YOUR_API_KEY"
with your actual CoinPaprika API key.
index.js
file, and in your terminal, run the following command:
Ctrl+C
in your terminal.
subscribePayload
to include other cryptocurrencies you’re interested in."type": "module"
to your package.json
"btc-bitcoin"
, "eth-ethereum"
)