{"id":21909357,"url":"https://github.com/datalayer/jupyter-kernel-client","last_synced_at":"2025-10-09T12:31:20.485Z","repository":{"id":265081808,"uuid":"895016489","full_name":"datalayer/jupyter-kernel-client","owner":"datalayer","description":"🪐 Jupyter Kernel Client through HTTP and WebSocket.","archived":false,"fork":false,"pushed_at":"2025-09-29T09:48:14.000Z","size":134,"stargazers_count":13,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T11:37:31.546Z","etag":null,"topics":["client","jupyter","kernel"],"latest_commit_sha":null,"homepage":"https://datalayer.ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datalayer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["datalayer"]}},"created_at":"2024-11-27T12:11:02.000Z","updated_at":"2025-09-29T09:48:18.000Z","dependencies_parsed_at":"2024-12-12T16:28:07.335Z","dependency_job_id":"2b47e3e1-448c-40fa-bc24-97ffe117fb91","html_url":"https://github.com/datalayer/jupyter-kernel-client","commit_stats":null,"previous_names":["datalayer/jupyter-kernel-client"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/datalayer/jupyter-kernel-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalayer%2Fjupyter-kernel-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalayer%2Fjupyter-kernel-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalayer%2Fjupyter-kernel-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalayer%2Fjupyter-kernel-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datalayer","download_url":"https://codeload.github.com/datalayer/jupyter-kernel-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalayer%2Fjupyter-kernel-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001443,"owners_count":26083078,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["client","jupyter","kernel"],"created_at":"2024-11-28T17:17:09.488Z","updated_at":"2025-10-09T12:31:20.480Z","avatar_url":"https://github.com/datalayer.png","language":"Python","funding_links":["https://github.com/sponsors/datalayer"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n  ~ Copyright (c) 2023-2024 Datalayer, Inc.\n  ~\n  ~ BSD 3-Clause License\n--\u003e\n\n[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)\n\n[![Become a Sponsor](https://img.shields.io/static/v1?label=Become%20a%20Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026style=flat\u0026color=1ABC9C)](https://github.com/sponsors/datalayer)\n\n# 🪐 Jupyter Kernel Client through HTTP and WebSocket\n\n[![Github Actions Status](https://github.com/datalayer/jupyter-kernel-client/workflows/Build/badge.svg)](https://github.com/datalayer/jupyter-kernel-client/actions/workflows/build.yml)\n[![PyPI - Version](https://img.shields.io/pypi/v/jupyter-kernel-client)](https://pypi.org/project/jupyter-kernel-client)\n\n`Jupyter Kernel Client` allows you to connect to live Jupyter Kernels through HTTP and WebSocket.\n\n\u003e A `Kernel` is the process responsible to execute the notebook code.\n\n`Jupyter Kernel Client` also provides a easy to use interactive Konsole (console for **K**ernels aka REPL, Read-Evaluate-Print-Loop).\n\nTo install the library, run the following command.\n\n```bash\npip install jupyter_kernel_client\n```\n\n## Usage\n\nCheck you have a Jupyter Server with ipykernel running somewhere. You can install those packages with the following command.\n\n```bash\npip install jupyter-server ipykernel\n```\n\n1. Start a Jupyter Server.\n\n```bash\n# make jupyter-server\njupyter server --port 8888 --ServerApp.port_retries 0 --IdentityProvider.token MY_TOKEN\n```\n\n2. Launch a IPython REPL in a terminal with `ipython` (or `jupyter console`). Execute the following snippet (update the server_url and token if needed).\n\n```py\nimport os\n\nfrom platform import node\nfrom jupyter_kernel_client import KernelClient\n\nwith KernelClient(server_url=\"http://localhost:8888\", token=\"MY_TOKEN\") as kernel:\n    code = \"\"\"import os\nfrom platform import node\nprint(f\"Hey {os.environ.get('USER', 'John Smith')} from {node()}.\")\n\"\"\"\n    reply = kernel.execute(code)\n    print(reply)\n    assert reply[\"execution_count\"] == 1\n    assert reply[\"outputs\"] == [\n        {\n            \"output_type\": \"stream\",\n            \"name\": \"stdout\",\n            \"text\": f\"Hey {os.environ.get('USER', 'John Smith')} from {node()}.\\n\",\n        }\n    ]\n    assert reply[\"status\"] == \"ok\"\n```\n\nCheck the response.\n\n```json\n{\"execution_count\": 1, \"outputs\": [{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": \"Hey echarles from eric.\\n\"}], \"status\": \"ok\"}\n```\n\nInstead of using the kernel client as context manager, you can call the `start()` and `stop()` methods.\n\n```py\nfrom jupyter_kernel_client import KernelClient\n\nkernel = KernelClient(server_url=\"http://localhost:8888\", token=\"MY_TOKEN\")\nkernel.start()\nreply = kernel.execute(code)\nprint(reply)\nkernel.stop()\n```\n\n## Connect to an existing Kernel\n\nFirst start JupyterLab, open a Notebook with a Kernel and take not of the `Kernel ID`.\n\n\u003e TODO: Document how to get the `Kernel ID`.\n\n```bash\nmake jupyterlab\n```\n\nYou can now connect to the existing Kernel and run code (do not invoke `stop`).\n\n```py\nfrom jupyter_kernel_client import KernelClient\n\nkernel = KernelClient(server_url=\"http://localhost:8888\", kernel_id=\"83ef59b7-9c78-40bd-8cc2-4447635e7d0b\", token=\"MY_TOKEN\")\nkernel.start()\nreply = kernel.execute(\"x=1\")\nprint(reply)\n```\n\n### Jupyter Konsole aka Console for Kernels\n\nThis package can be used to open a Jupyter Console to a Jupyter Kernel 🐣.\n\n1. Install the optional dependencies.\n\n```bash\npip install jupyter-kernel-client[konsole]\n```\n\n2. Start a Jupyter Server.\n\n```bash\n# make jupyter-server\njupyter server --port 8888 --ServerApp.port_retries 0 --IdentityProvider.token MY_TOKEN\n```\n\n3. Start the konsole and execute code.\n\n```bash\n# make jupyter-konsole\njupyter konsole --url http://localhost:8888 --token MY_TOKEN\n```\n\n```bash\n[KonsoleApp] KernelHttpManager created a new kernel:...\nJupyter Konsole...\n\nIn [1]: 1+1\n2\n```\n\n## Uninstall\n\nTo remove the library, execute the following command.\n\n```bash\npip uninstall jupyter_kernel_client\n```\n\n## Contributing\n\n### Development install\n\n```bash\n# Clone the repo to your local environment\n# Change directory to the jupyter_kernel_client directory\n# Install package in development mode, this will automatically enable the server extension.\npip install -e \".[konsole,test,lint,typing]\"\n```\n\n### Running Tests\n\nInstall dependencies.\n\n```bash\npip install -e \".[test]\"\n```\n\nRun the python tests.\n\n```bash\npytest\n```\n\n### Development uninstall\n\n```bash\npip uninstall jupyter_kernel_client\n```\n\n### Packaging the library\n\nSee [RELEASE](RELEASE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalayer%2Fjupyter-kernel-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatalayer%2Fjupyter-kernel-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalayer%2Fjupyter-kernel-client/lists"}