Declare Subscribe Dataīefore we can subscribe to a websocket stream, we must define the subscription for which we want to connect. Private_key = 'e6238b0de3cdf19c7861f8e8f5d137ce7113ac1e884b191a14bbb2.'Īpi_client = shrimpy.ShrimpyApiClient(public_key, private_key)Ĭlient = shrimpy.ShrimpyWsClient(error_handler, raw_token)Ĥ minutes now - it’s going to be close. This will help you manage your websocket connection and subscriptions. You can get this client by creating an API client, which is created by passing in your public and private API keys. This will make it easy for them to see the price of the cryptocurrency they want to buy instead of leaving your website to find that information. Don’t forget to first get the token which is required to create the client. Add a crypto price ticker (or bitcoin price widget) to make your website even more useful to your visitors. Ticker = msg) - 1]Ĭreate a client object by calling into the Shrimpy library. Since we can receive multiple trades per message, we will only consider the last trade in the message to be the current ticker price. This handler will simply print the price of each trade which is received through the trade websocket. To receive data out of the websocket, we need to create a handler. The Shrimpy library has already been installed, so import it into your script. Stretch those fingers because we’re about to set a new record for the fastest time anyone has ever connected to a crypto exchange websocket. Some data which is available through the APIs includes candlestick (OHLCV) data, historical order book snapshots, and live trade data.ģ minutes passed - Uh oh, we haven’t even started coding yet. Make sure to enable “data” permissions on these keys. Save the public and private keys for later use. The master key is how you sign requests and access crypto market data. Once you’ve signed up for an account, create a new master key. This service will be used to access the exchange websockets. Generate API KeysĪfter installing the Shrimpy Python Library, register for a Shrimpy Developer API account. Run the following command to install Shrimpy: pip install shrimpy-pythonġ minute down - already 20% done. Install Librariesīefore we can write our Python script to connect to exchange websockets, we need to install a library. That’s a bold assertion, so let’s not waste any time. A 5-minute tutorial to connect to cryptocurrency exchange websockets.Ĭheck the time - I have 5 minutes to get you connected to a cryptocurrency exchange’s websocket.
0 Comments
Leave a Reply. |