Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public_client = cbpro.PublicClient()
public_client.get_products()
```

- [get_single_product](https://docs.pro.coinbase.com//#get-single-product)
```python
public_client.get_single_product('BTC-USD')
```

- [get_product_order_book](https://docs.pro.coinbase.com/#get-product-order-book)
```python
# Get the order book at the default level.
Expand Down
30 changes: 30 additions & 0 deletions cbpro/public_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ def get_products(self):
"""
return self._send_message('get', '/products')

def get_single_product(self, product_id):
"""Get market data for a specific currency pair.

Args:
product_id (str): Product

Returns:
dict: Info about specific currency pairs. Example::
{
"id": "BTC-USD",
"display_name": "BTC/USD",
"base_currency": "BTC",
"quote_currency": "USD",
"base_increment": "0.00000001",
"quote_increment": "0.01000000",
"base_min_size": "0.00100000",
"base_max_size": "280.00000000",
"min_market_funds": "5",
"max_market_funds": "1000000",
"status": "online",
"status_message": "",
"cancel_only": false,
"limit_only": false,
"post_only": false,
"trading_disabled": false
}

"""
return self._send_message('get', '/products/{}'.format(product_id))

def get_product_order_book(self, product_id, level=1):
"""Get a list of open orders for a product.

Expand Down
4 changes: 4 additions & 0 deletions tests/test_public_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def test_get_products(self, client):
r = client.get_products()
assert type(r) is list

def test_get_single_product(self, client):
r = client.get_single_product("BTC-USD")
assert isinstance(r, dict)

@pytest.mark.parametrize('level', [1, 2, 3, None])
def test_get_product_order_book(self, client, level):
r = client.get_product_order_book('BTC-USD', level=level)
Expand Down