Skip to content

amberdata/amberdata-example-marketdata

Repository files navigation

amberdata-example-marketdata

Build your own websocket event stream for crypto market data using Amberdata.io! Example code uses Amberdata's Websockets

Check out the demo page!

Clone:

git clone git@github.com:amberdata/amberdata-example-marketdata.git

1. Get API Key

Go to amberdata.io and click "Get started"

2. Build:

Building with Amberdata.io is as simple as a few a few lines of code:

For Historical OHLCV -

let config = {headers: {"x-api-key": "YOUR_API_KEY_HERE"}};
const getHistoricalOHLCV = (pair) => axios.get(`https://web3api.io/api/v1/market/ohlcv/${pair}/historical`, config);

See source here.

For live order book updates -

// Create WebSocket connection.
const socket = new WebSocket('wss://ws.web3api.io?x-api-key=YOUR_API_KEY_HERE');

// Connection opened
socket.addEventListener('open', function (event) {
    console.log('Connection opened - ', event);
    socket.send(`{"jsonrpc":"2.0","id":0,"method":"subscribe","params":["market:orders",{"pair":"eth_btc","exchange":"gdax"}]}`);
});

// Listen for messages
socket.addEventListener('message', responseHandler);

See source here.

Resources

Licensing

This project is licensed under the Apache Licence 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published