Crypto.com websocket api client
=================================
[![Build Status](https://travis-ci.com/maxpowel/crypto_com_client.svg?branch=master)](https://travis-ci.com/maxpowel/crypto_com_client)
[![Maintainability](https://api.codeclimate.com/v1/badges/9c2c51fed72ca3aeacf6/maintainability)](https://codeclimate.com/github/maxpowel/crypto_com_client/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/9c2c51fed72ca3aeacf6/test_coverage)](https://codeclimate.com/github/maxpowel/crypto_com_client/test_coverage)
This is a low level api client, it just connects the exchange api with your python code in the most simple way. Over
this library, you can build your awesome applications or high level api.
For more information, check the [library documentation](https://maxpowel.github.io/crypto_com_client/), the [official documentation](https://exchange-docs.crypto.com/) and the `examples` directory.
Features
--------
This library is optimized to be small, fast and secure.
* Fully tested: 100% code coverage
* Simple: It just does one thing, but it does it right
* Fast: Relies on asyncio so latency and memory usage is near zero (much better than threading or multiprocessing)
* No forced dependencies: Just `websockets` and `orjson`. No super modern cool features that you probably don't want
Getting started
---------------
There are two kinds of `apis`, the `user` and `market`.
The `user` type requires providing api credentials (access and secret key)
Before using the library, you have to install it:
```bash
pip install crypto_com_client
```
The most simple example, subscribing to an `orderbook`:
```python
from crypto_com.crypto_com import MarketClient
import asyncio
import logging
logging.basicConfig(level=logging.INFO)
async def run():
async with MarketClient() as client:
await client.subscribe(["book.CRO_USDC.10"])
while True:
event = await client.next_event()
print(event)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
If you want to use the `user` api first get you api `key` and `secret`.
```python
from crypto_com import UserClient
import asyncio
import os
import logging
logging.basicConfig(level=logging.INFO)
async def run():
async with UserClient(
api_key=os.environ["API_KEY"],
api_secret=os.environ["API_SECRET"]
) as client:
await client.send(
client.build_message(
method="private/get-open-orders",
params={
"instrument_name": "CRO_USDC",
"page_size": 10,
"page": 0
}
)
)
event = await client.next_event()
print(event)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
With these two examples you can use the whole api. Just check the API documentation to know the different methods
and parameters.
Contributing
============
If you have any suggestion, detect any bug or want any feature, please open an `issue` so we can discuss it.
Tests
=====
To run the tests just run `tox`
It will run in first instance `flake8`, then `pylint` and finally `pytest` with code coverage check.
The only rule ignored is `max-line-length=120` basically because nowadays monitors are big enough for this.
Websockets import has E0611 disabled because pylint does not process `__all__` correctly
Raw data
{
"_id": null,
"home_page": "https://github.com/maxpowel/crypto_com_client",
"name": "crypto-com-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "websocket,client,crypto",
"author": "Alvaro Garcia",
"author_email": "maxpowel@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2a/42/1279c9bf1f20cb9af94919d8dd5c286cb634390a5b241e4092ccc227a1b9/crypto-com-client-1.2.tar.gz",
"platform": null,
"description": "Crypto.com websocket api client\n=================================\n[![Build Status](https://travis-ci.com/maxpowel/crypto_com_client.svg?branch=master)](https://travis-ci.com/maxpowel/crypto_com_client)\n[![Maintainability](https://api.codeclimate.com/v1/badges/9c2c51fed72ca3aeacf6/maintainability)](https://codeclimate.com/github/maxpowel/crypto_com_client/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/9c2c51fed72ca3aeacf6/test_coverage)](https://codeclimate.com/github/maxpowel/crypto_com_client/test_coverage)\n\n\nThis is a low level api client, it just connects the exchange api with your python code in the most simple way. Over\nthis library, you can build your awesome applications or high level api.\nFor more information, check the [library documentation](https://maxpowel.github.io/crypto_com_client/), the [official documentation](https://exchange-docs.crypto.com/) and the `examples` directory.\n\nFeatures\n--------\nThis library is optimized to be small, fast and secure. \n * Fully tested: 100% code coverage\n * Simple: It just does one thing, but it does it right\n * Fast: Relies on asyncio so latency and memory usage is near zero (much better than threading or multiprocessing)\n * No forced dependencies: Just `websockets` and `orjson`. No super modern cool features that you probably don't want\n\n\nGetting started\n---------------\nThere are two kinds of `apis`, the `user` and `market`. \nThe `user` type requires providing api credentials (access and secret key)\n\nBefore using the library, you have to install it:\n```bash\npip install crypto_com_client\n```\n\nThe most simple example, subscribing to an `orderbook`:\n\n```python\nfrom crypto_com.crypto_com import MarketClient\nimport asyncio\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\n\nasync def run():\n async with MarketClient() as client:\n await client.subscribe([\"book.CRO_USDC.10\"])\n while True:\n event = await client.next_event()\n print(event)\n\n\nif __name__ == \"__main__\":\n loop = asyncio.get_event_loop()\n loop.run_until_complete(run())\n```\n\nIf you want to use the `user` api first get you api `key` and `secret`.\n\n```python\nfrom crypto_com import UserClient\nimport asyncio\nimport os\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\n\nasync def run():\n async with UserClient(\n api_key=os.environ[\"API_KEY\"],\n api_secret=os.environ[\"API_SECRET\"]\n ) as client:\n await client.send(\n client.build_message(\n method=\"private/get-open-orders\",\n params={\n \"instrument_name\": \"CRO_USDC\",\n \"page_size\": 10,\n \"page\": 0\n }\n )\n )\n event = await client.next_event()\n print(event)\n\n\nif __name__ == \"__main__\":\n loop = asyncio.get_event_loop()\n loop.run_until_complete(run())\n\n```\n\nWith these two examples you can use the whole api. Just check the API documentation to know the different methods\nand parameters.\n\nContributing\n============\nIf you have any suggestion, detect any bug or want any feature, please open an `issue` so we can discuss it.\n\n\nTests\n=====\nTo run the tests just run `tox`\n\nIt will run in first instance `flake8`, then `pylint` and finally `pytest` with code coverage check.\nThe only rule ignored is `max-line-length=120` basically because nowadays monitors are big enough for this.\nWebsockets import has E0611 disabled because pylint does not process `__all__` correctly",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Crypto.com websocket api client",
"version": "1.2",
"project_urls": {
"Documentation": "https://github.com/maxpowel/crypto_com_client",
"Homepage": "https://github.com/maxpowel/crypto_com_client",
"Repository": "https://github.com/maxpowel/crypto_com_client"
},
"split_keywords": [
"websocket",
"client",
"crypto"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b22c5cde147655ca32581c5e4ba5c14ca3fc52ac8afbfa7feb96a1d038f58ccf",
"md5": "412998a1a6521cf1969a2b90b17698cb",
"sha256": "427d032c07a3863c2790753f8270c3032a212bc6ddcf00d726eec0555caf6aae"
},
"downloads": -1,
"filename": "crypto_com_client-1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "412998a1a6521cf1969a2b90b17698cb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8487,
"upload_time": "2024-02-08T09:40:07",
"upload_time_iso_8601": "2024-02-08T09:40:07.950087Z",
"url": "https://files.pythonhosted.org/packages/b2/2c/5cde147655ca32581c5e4ba5c14ca3fc52ac8afbfa7feb96a1d038f58ccf/crypto_com_client-1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2a421279c9bf1f20cb9af94919d8dd5c286cb634390a5b241e4092ccc227a1b9",
"md5": "256e4a9fa87a4841a7393bdb74ab7084",
"sha256": "0a9a7744612ec1612fdb0c6d0cb3e7bd2256c07b40f0e33f41f6357877af2fb6"
},
"downloads": -1,
"filename": "crypto-com-client-1.2.tar.gz",
"has_sig": false,
"md5_digest": "256e4a9fa87a4841a7393bdb74ab7084",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8387,
"upload_time": "2024-02-08T09:40:03",
"upload_time_iso_8601": "2024-02-08T09:40:03.786785Z",
"url": "https://files.pythonhosted.org/packages/2a/42/1279c9bf1f20cb9af94919d8dd5c286cb634390a5b241e4092ccc227a1b9/crypto-com-client-1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-08 09:40:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maxpowel",
"github_project": "crypto_com_client",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "crypto-com-client"
}