{"id":20657493,"url":"https://github.com/sammchardy/python-kucoin","last_synced_at":"2025-05-14T18:06:43.400Z","repository":{"id":37739873,"uuid":"110206126","full_name":"sammchardy/python-kucoin","owner":"sammchardy","description":"Kucoin REST and Websocket API python implementation","archived":false,"fork":false,"pushed_at":"2024-12-19T08:44:33.000Z","size":542,"stargazers_count":365,"open_issues_count":54,"forks_count":152,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-05-14T18:06:33.737Z","etag":null,"topics":["bitcoin","cryptocurrency","kucoin","kucoin-api","python","python3","rest","websocket"],"latest_commit_sha":null,"homepage":"https://python-kucoin.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sammchardy.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-10T05:20:27.000Z","updated_at":"2025-04-20T21:12:38.000Z","dependencies_parsed_at":"2022-07-12T16:44:13.034Z","dependency_job_id":"4e72cf89-2b16-4f54-a6cc-07f0775206a6","html_url":"https://github.com/sammchardy/python-kucoin","commit_stats":{"total_commits":150,"total_committers":12,"mean_commits":12.5,"dds":0.1266666666666667,"last_synced_commit":"6245e0a2a1bec59d02a5ca26917380bd9d852ce0"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammchardy%2Fpython-kucoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammchardy%2Fpython-kucoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammchardy%2Fpython-kucoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammchardy%2Fpython-kucoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sammchardy","download_url":"https://codeload.github.com/sammchardy/python-kucoin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198514,"owners_count":22030965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","cryptocurrency","kucoin","kucoin-api","python","python3","rest","websocket"],"created_at":"2024-11-16T18:21:05.895Z","updated_at":"2025-05-14T18:06:38.391Z","avatar_url":"https://github.com/sammchardy.png","language":"Python","readme":"===============================\nWelcome to python-kucoin v2.2.0\n===============================\n\n.. image:: https://img.shields.io/pypi/v/python-kucoin.svg\n    :target: https://pypi.python.org/pypi/python-kucoin\n\n.. image:: https://img.shields.io/pypi/l/python-kucoin.svg\n    :target: https://pypi.python.org/pypi/python-kucoin\n\n.. image:: https://img.shields.io/coveralls/sammchardy/python-kucoin.svg\n    :target: https://coveralls.io/github/sammchardy/python-kucoin\n\n.. image:: https://img.shields.io/pypi/wheel/python-kucoin.svg\n    :target: https://pypi.python.org/pypi/python-kucoin\n\n.. image:: https://img.shields.io/pypi/pyversions/python-kucoin.svg\n    :target: https://pypi.python.org/pypi/python-kucoin\n\nThis is an unofficial Python wrapper for the `Kucoin exchanges REST and Websocket API v3 \u003chttps://docs.kucoin.com/\u003e`_.\nI am in no way affiliated with `Kucoin \u003chttps://www.kucoin.com/ucenter/signup?rcode=E5wkqe\u003e`_, use at your own risk.\n\n\nPyPi\n  https://pypi.python.org/pypi/python-kucoin\n\nSource code\n  https://github.com/sammchardy/python-kucoin\n\nDocumentation\n  https://python-kucoin.readthedocs.io/en/latest/\n\nExamples\n  https://github.com/sammchardy/python-kucoin/tree/master/examples\n\n\nFeatures\n--------\n\n- Implementation of REST endpoints\n- Spot and Futures\n- Sync and Async suport\n- Simple handling of authentication\n- Response exception handling\n- Implement websockets (note only python3.5+)\n- Proxy support\n\nTODO\n----\n\n- L2 and L3 Local Order Books\n\nQuick Start\n-----------\n\nRegister an account with `Kucoin \u003chttps://www.kucoin.com/ucenter/signup?rcode=E42cWB\u003e`_.\n\n`Generate an API Key \u003chttps://kucoin.com/account/api\u003e`_.\n\n.. code:: bash\n\n    pip install python-kucoin\n\n.. code:: python\n\n    from kucoin import Client\n\n    api_key = '\u003capi_key\u003e'\n    api_secret = '\u003capi_secret\u003e'\n    api_passphrase = '\u003capi_passphrase\u003e'\n\n    client = Client(api_key, api_secret, api_passphrase)\n\n    # get currencies\n    currencies = client.get_currencies()\n\n    # get market depth\n    depth = client.get_order_book('KCS-BTC')\n\n    # get symbol klines\n    klines = client.get_kline_data('KCS-BTC')\n\n    # get list of markets\n    markets = client.get_markets()\n\n    # place a market buy order\n    order = client.create_market_order('NEO', Client.SIDE_BUY, size=20)\n\n    # get list of active orders\n    orders = client.get_active_orders('KCS-BTC')\n\n\nAsync\n-----\n\n.. code:: python\n\n    from kucoin import AsyncClient\n\n    api_key = '\u003capi_key\u003e'\n    api_secret = '\u003capi_secret\u003e'\n    api_passphrase = '\u003capi_passphrase\u003e'\n\n    client = AsyncClient(api_key, api_secret, api_passphrase)\n\n    # get currencies\n    currencies = await client.get_currencies()\n\nWebsockets\n----------\n\nNote only for python3.5+\n\n.. code:: python\n\n    import asyncio\n\n    from kucoin.client import Client\n    from kucoin.asyncio import KucoinSocketManager\n\n    api_key = '\u003capi_key\u003e'\n    api_secret = '\u003capi_secret\u003e'\n    api_passphrase = '\u003capi_passphrase\u003e'\n\n\n    async def main():\n        global loop\n\n        # callback function that receives messages from the socket\n        async def handle_evt(msg):\n            if msg['topic'] == '/market/ticker:ETH-USDT':\n                print(f'got ETH-USDT tick:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/snapshot:BTC':\n                print(f'got BTC market snapshot:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/snapshot:KCS-BTC':\n                print(f'got KCS-BTC symbol snapshot:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/ticker:all':\n                print(f'got all market snapshot:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/account/balance':\n                print(f'got account balance:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/level2:KCS-BTC':\n                print(f'got L2 msg:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/match:BTC-USDT':\n                print(f'got market match msg:{msg[\"data\"]}')\n\n            elif msg['topic'] == '/market/level3:BTC-USDT':\n                if msg['subject'] == 'trade.l3received':\n                    if msg['data']['type'] == 'activated':\n                        # must be logged into see these messages\n                        print(f\"L3 your order activated: {msg['data']}\")\n                    else:\n                        print(f\"L3 order received:{msg['data']}\")\n                elif msg['subject'] == 'trade.l3open':\n                    print(f\"L3 order open: {msg['data']}\")\n                elif msg['subject'] == 'trade.l3done':\n                    print(f\"L3 order done: {msg['data']}\")\n                elif msg['subject'] == 'trade.l3match':\n                    print(f\"L3 order matched: {msg['data']}\")\n                elif msg['subject'] == 'trade.l3change':\n                    print(f\"L3 order changed: {msg['data']}\")\n\n        client = Client(api_key, api_secret, api_passphrase)\n\n        ksm = await KucoinSocketManager.create(loop, client, handle_evt)\n\n        # for private topics such as '/account/balance' pass private=True\n        ksm_private = await KucoinSocketManager.create(loop, client, handle_evt, private=True)\n\n        # Note: try these one at a time, if all are on you will see a lot of output\n\n        # ETH-USDT Market Ticker\n        await ksm.subscribe('/market/ticker:ETH-USDT')\n        # BTC Symbol Snapshots\n        await ksm.subscribe('/market/snapshot:BTC')\n        # KCS-BTC Market Snapshots\n        await ksm.subscribe('/market/snapshot:KCS-BTC')\n        # All tickers\n        await ksm.subscribe('/market/ticker:all')\n        # Level 2 Market Data\n        await ksm.subscribe('/market/level2:KCS-BTC')\n        # Market Execution Data\n        await ksm.subscribe('/market/match:BTC-USDT')\n        # Level 3 market data\n        await ksm.subscribe('/market/level3:BTC-USDT')\n        # Account balance - must be authenticated\n        await ksm_private.subscribe('/account/balance')\n\n        while True:\n            print(\"sleeping to keep loop open\")\n            await asyncio.sleep(20, loop=loop)\n\n\n    if __name__ == \"__main__\":\n\n        loop = asyncio.get_event_loop()\n        loop.run_until_complete(main())\n\n\nFor more `check out the documentation \u003chttps://python-kucoin.readthedocs.io/en/latest/\u003e`_.\n\n\nOther Exchanges\n---------------\n\n- If you use `Binance \u003chttps://accounts.binance.com/register?ref=PGDFCE46\u003e`_ check out my `python-binance \u003chttps://github.com/sammchardy/python-binance\u003e`_ library.\n- Check out `CCXT \u003chttps://github.com/ccxt/ccxt\u003e`_ for more than 100 crypto exchanges with a unified trading API.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammchardy%2Fpython-kucoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammchardy%2Fpython-kucoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammchardy%2Fpython-kucoin/lists"}