Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Ansyncronous Python websocket client for the Coinbase Pro virtual currency trading platform.

Project description


An Asyncronous Python WebSocket Client for Coinbase Pro

Version Build Status Documentation Status

Quick Links: Documentation - Source Code


CoPrA (Coinbase Pro Async) is an asyncronous websocket client written in Python for use with the Coinbase Pro digital currency trading platform. To learn about Coinbase Pro’s WebSocket service including the available channels and the data they provide, please see Coinbase Pro’s WebSocket API documentation.


  • Coinbase Pro WebSocket client class with callback hooks for managing every phase of a WebSocket session
  • supports user authentication
  • compatible with Python 3.5 or greater
  • built on Autobahn|Python, the open-source (MIT) real-time framework for web, mobile & the Internet of Things.
  • utilizes Python’s asyncio concurrency framework
  • open source (MIT license)


While copra.websocket.Client is meant to be overridden, but it can be used ‘as is’ to test the module through the command line.


import asyncio

from copra.websocket import Channel, Client

loop = asyncio.get_event_loop()

ws = Client(loop, Channel('heartbeat', 'BTC-USD'))

except KeyboardInterrupt:

Running the above:

$ python3
{'type': 'subscriptions', 'channels': [{'name': 'heartbeat', 'product_ids': ['BTC-USD']}]}
{'type': 'heartbeat', 'last_trade_id': 45950713, 'product_id': 'BTC-USD', 'sequence': 6254273323, 'time': '2018-07-05T22:36:30.823000Z'}
{'type': 'heartbeat', 'last_trade_id': 45950714, 'product_id': 'BTC-USD', 'sequence': 6254273420, 'time': '2018-07-05T22:36:31.823000Z'}
{'type': 'heartbeat', 'last_trade_id': 45950715, 'product_id': 'BTC-USD', 'sequence': 6254273528, 'time': '2018-07-05T22:36:32.823000Z'}
{'type': 'heartbeat', 'last_trade_id': 45950715, 'product_id': 'BTC-USD', 'sequence': 6254273641, 'time': '2018-07-05T22:36:33.823000Z'}
{'type': 'heartbeat', 'last_trade_id': 45950715, 'product_id': 'BTC-USD', 'sequence': 6254273758, 'time': '2018-07-05T22:36:34.823000Z'}
{'type': 'heartbeat', 'last_trade_id': 45950720, 'product_id': 'BTC-USD', 'sequence': 6254273910, 'time': '2018-07-05T22:36:35.824000Z'}

CoPrA supports authentication allowing you to receive only messages specific to your user account. NOTE: This requires registering an API key at Coinbase Pro.


import asyncio

from copra.websocket import Channel, Client


loop = asyncio.get_event_loop()

channel = Channel('user', 'LTC-USD')

ws = Client(loop, channel, auth=True, key=KEY, secret=SECRET, passphrase=PASSPHRASE)

except KeyboardInterrupt:

Running the above:

$ python3
{'type': 'subscriptions', 'channels': [{'name': 'user', 'product_ids': ['LTC-USD']}]}
{'type': 'received', 'order_id': '42d2677d-0d37-435f-a776-e9e7f81ff22b', 'order_type': 'limit', 'size': '50.00000000', 'price': '1.00000000', 'side': 'buy', 'client_oid': '00098b59-4ac9-4ff8-ba16-bd2ef673f7b7', 'product_id': 'LTC-USD', 'sequence': 2311323871, 'user_id': '642394321fdf8343c4006432', 'profile_id': '039ff148-d490-45f9-9aed-0d1f6412884', 'time': '2018-07-07T17:33:29.755000Z'}
{'type': 'open', 'side': 'buy', 'price': '1.00000000', 'order_id': '42d2677d-0d37-435f-a776-e9e7f81ff22b', 'remaining_size': '50.00000000', 'product_id': 'LTC-USD', 'sequence': 2311323872, 'user_id': '642394321fdf8343c4006432', 'profile_id': '039ff148-d490-45f9-9aed-0d1f6412884', 'time': '2018-07-07T17:33:29.755000Z'}


We use SemVer for versioning. For the versions available, see the tags on this repository.


This project is licensed under the MIT License - see the LICENSE file for details


Tony Podlaski -

See also the list of contributers who participated in this project.


Please read CONTRIBUTING.rst for details on our code of conduct, and the process for submitting pull requests to us.


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


0.1.0 (2018-07-06)

  • First release on PyPI.

0.2.0 (2018-07-07)

  • Added Client authentication.

0.3.0 (2018-07-09)

  • Added reconnect option to Client.

0.4.0 (2018-07-10)

  • Added subscribe and unsubscribe methods to Client.

1.0.0 (2018-07-12)

  • Added full documentation of the CoPrA API.

1.0.1 (2018-07-12)

  • Fixed typos in the documentation.

1.0.2 (2018-07-12)

  • Added Examples page to the documentation.

1.0.3 (2018-07-16)

  • More documentation typos fixed.

1.0.4 - 1.0.5 (2018-07-17)

  • Non-API changes.

1.0.6 (2018-08-19)

  • Updated Autobahn requirement to 18.8.1

1.0.7 (2018-08-19)

  • Modified Travis config to test against Python 3.7.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
copra-1.0.7-py3-none-any.whl (7.7 kB) Copy SHA256 hash SHA256 Wheel py3 Aug 19, 2018
copra-1.0.7.tar.gz (23.0 kB) Copy SHA256 hash SHA256 Source None Aug 19, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page