# Notbank Python SDK
[main page](https://notbank.exchange)
[sign up in Notbank](https://www.cryptomkt.com/account/register).
## Installation
To install Notbank use pip
```bash
pip install notbank
```
## Documentation
This sdk makes use of the [api](https://apidoc.notbank.exchange) of Notbank.
## Quick start
### Client creation
There are two communication protocols supported by the Notbank client. Communication via websocket, and via rest. Communication via websocket requires connection and permits subscriptions, other than that they are equivalent.
```python
from notbank_python_sdk.requests_models import *
from notbank_python_sdk.client_connection_factory import new_rest_client_connection
from notbank_python_sdk.error import NotbankException
from notbank_python_sdk.notbank_client import NotbankClient
try:
# an rest client via http
rest_connection = new_rest_client_connection()
client = NotbankClient(rest_connection)
except NotbankException as e:
print(e)
```
### Error handling
All internal notbank client and notbank server errors inherit from NotbankException, and all client methods may throw it (e.g. invalid request, request timeout, ...)
```python
# client : NotbankClient : ....
try:
orderbook = client.get_order_book(OrderBookRequest("BTCUSDT", 1, 1))
except NotbankException as e:
print(e)
```
### Put order at the top of book example
```python
import random
from decimal import Decimal
from notbank_python_sdk.notbank_client import NotbankClient
from notbank_python_sdk.client_connection_factory import new_rest_client_connection
account_id: int = 13 # must be user account id
# instantiate client
connection = new_rest_client_connection()
client = NotbankClient(connection)
# authentication (same for rest client or websocket client)
authenticate = client.authenticate(
AuthenticateRequest(
api_public_key="api-public-key",
api_secret_key="api-secret-key",
user_id="user-id",
)
)
if not authenticate.authenticated:
raise Exception("client not authenticated")
# get USDT user balance (also known as position)
positions = client.get_account_positions(
GetAccountPositionsRequest(account_id))
usdt_balance = None
product = "USDT"
market_pair = "BTCUSDT"
for position in positions:
if position.product_symbol == product:
usdt_balance = position
if usdt_balance is None:
raise Exception("user has no balance")
# define order_amount (between all usdt_balance and half usdt_balance)
total_balance = usdt_balance.amount
quantity_to_spend = total_balance - \
Decimal(random.random()) * (total_balance/2)
# define order_price (around market top)
orderbook = client.get_order_book(
OrderBookRequest(market_pair, level=2, depth=5))
top_orderbook = orderbook.bids[0]
delta = Decimal(random.randrange(10, 100))/1000
order_price = top_orderbook.price + delta
order_quantity = quantity_to_spend / order_price
# send order
instrument = client.get_instrument_by_symbol(market_pair)
request = SendOrderRequest(
instrument=instrument,
account_id=account_id,
time_in_force=TimeInForce.GTC,
side=Side.Buy,
quantity=order_quantity,
limit_price=order_price,
order_type=OrderType.Limit,
)
response = client.send_order(request)
# handle order result
if response.status == SendOrderStatus.REJECTED:
# order was rejected
raise Exception("rejected order")
else:
# order was accepted
order_id = response.order_id
print(order_id)
# close client
client.close()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/notbank-exchange/notbank-python",
"name": "notbank",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "api, notbank, cryptomkt, cryptomarket, bitcoin, client",
"author": "Notbank",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/8a/a3/1545a073773cc754e32629113f14e5128d3ca3ca285df4d134b668d18da7/notbank-1.2.1a1.tar.gz",
"platform": null,
"description": "# Notbank Python SDK\n\n[main page](https://notbank.exchange)\n\n[sign up in Notbank](https://www.cryptomkt.com/account/register).\n\n## Installation\n\nTo install Notbank use pip\n\n```bash\npip install notbank\n```\n\n## Documentation\n\nThis sdk makes use of the [api](https://apidoc.notbank.exchange) of Notbank.\n\n## Quick start\n\n### Client creation\n\nThere are two communication protocols supported by the Notbank client. Communication via websocket, and via rest. Communication via websocket requires connection and permits subscriptions, other than that they are equivalent.\n\n```python\nfrom notbank_python_sdk.requests_models import *\nfrom notbank_python_sdk.client_connection_factory import new_rest_client_connection\nfrom notbank_python_sdk.error import NotbankException\nfrom notbank_python_sdk.notbank_client import NotbankClient\n\ntry:\n # an rest client via http\n rest_connection = new_rest_client_connection()\n client = NotbankClient(rest_connection)\nexcept NotbankException as e:\n print(e)\n```\n\n### Error handling\n\nAll internal notbank client and notbank server errors inherit from NotbankException, and all client methods may throw it (e.g. invalid request, request timeout, ...)\n\n```python\n# client : NotbankClient : ....\ntry:\n orderbook = client.get_order_book(OrderBookRequest(\"BTCUSDT\", 1, 1))\nexcept NotbankException as e:\n print(e)\n```\n\n### Put order at the top of book example\n\n```python\nimport random\nfrom decimal import Decimal\n\nfrom notbank_python_sdk.notbank_client import NotbankClient\nfrom notbank_python_sdk.client_connection_factory import new_rest_client_connection\n\naccount_id: int = 13 # must be user account id\n\n# instantiate client\nconnection = new_rest_client_connection()\nclient = NotbankClient(connection)\n\n# authentication (same for rest client or websocket client)\nauthenticate = client.authenticate(\n AuthenticateRequest(\n api_public_key=\"api-public-key\",\n api_secret_key=\"api-secret-key\",\n user_id=\"user-id\",\n )\n)\nif not authenticate.authenticated:\n raise Exception(\"client not authenticated\")\n\n# get USDT user balance (also known as position)\npositions = client.get_account_positions(\n GetAccountPositionsRequest(account_id))\nusdt_balance = None\nproduct = \"USDT\"\nmarket_pair = \"BTCUSDT\"\nfor position in positions:\n if position.product_symbol == product:\n usdt_balance = position\nif usdt_balance is None:\n raise Exception(\"user has no balance\")\n\n# define order_amount (between all usdt_balance and half usdt_balance)\ntotal_balance = usdt_balance.amount\nquantity_to_spend = total_balance - \\\n Decimal(random.random()) * (total_balance/2)\n\n# define order_price (around market top)\norderbook = client.get_order_book(\n OrderBookRequest(market_pair, level=2, depth=5))\ntop_orderbook = orderbook.bids[0]\ndelta = Decimal(random.randrange(10, 100))/1000\norder_price = top_orderbook.price + delta\norder_quantity = quantity_to_spend / order_price\n\n# send order\ninstrument = client.get_instrument_by_symbol(market_pair)\nrequest = SendOrderRequest(\n instrument=instrument,\n account_id=account_id,\n time_in_force=TimeInForce.GTC,\n side=Side.Buy,\n quantity=order_quantity,\n limit_price=order_price,\n order_type=OrderType.Limit,\n)\nresponse = client.send_order(request)\n\n# handle order result\nif response.status == SendOrderStatus.REJECTED:\n # order was rejected\n raise Exception(\"rejected order\")\nelse:\n # order was accepted\n order_id = response.order_id\n print(order_id)\n\n# close client\nclient.close()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Notbank API client library",
"version": "1.2.1a1",
"project_urls": {
"Homepage": "https://github.com/notbank-exchange/notbank-python"
},
"split_keywords": [
"api",
" notbank",
" cryptomkt",
" cryptomarket",
" bitcoin",
" client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d6b4e6dbeff3a38bee2ee36a184321251b6e65d780633c7d777169f0f0d8d0c5",
"md5": "48f9934119692012e8dcbca31a07820f",
"sha256": "cee4b99b282b9a0833bf5e60757cc6040236fed8023e42b9bf866710712863d4"
},
"downloads": -1,
"filename": "notbank-1.2.1a1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "48f9934119692012e8dcbca31a07820f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 97300,
"upload_time": "2025-07-08T19:54:02",
"upload_time_iso_8601": "2025-07-08T19:54:02.041112Z",
"url": "https://files.pythonhosted.org/packages/d6/b4/e6dbeff3a38bee2ee36a184321251b6e65d780633c7d777169f0f0d8d0c5/notbank-1.2.1a1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8aa31545a073773cc754e32629113f14e5128d3ca3ca285df4d134b668d18da7",
"md5": "80926995a425184c8e3b124577cfb56c",
"sha256": "e67a7e63aed70f11b8a1ea927f0029d2ef907e4cc19116fa00e9871e9e4d3c35"
},
"downloads": -1,
"filename": "notbank-1.2.1a1.tar.gz",
"has_sig": false,
"md5_digest": "80926995a425184c8e3b124577cfb56c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 56957,
"upload_time": "2025-07-08T19:54:03",
"upload_time_iso_8601": "2025-07-08T19:54:03.420539Z",
"url": "https://files.pythonhosted.org/packages/8a/a3/1545a073773cc754e32629113f14e5128d3ca3ca285df4d134b668d18da7/notbank-1.2.1a1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 19:54:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "notbank-exchange",
"github_project": "notbank-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "certifi",
"specs": [
[
"==",
"2021.10.8"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"2.0.12"
]
]
},
{
"name": "dacite",
"specs": [
[
"==",
"1.9.2"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.3"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.27.1"
]
]
},
{
"name": "simplejson",
"specs": [
[
"==",
"3.20.1"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"1.26.9"
]
]
},
{
"name": "websocket-client",
"specs": [
[
"==",
"1.6.1"
]
]
}
],
"lcname": "notbank"
}