{
 "kind": "tool",
 "slug": "websockets",
 "path": "tools/websockets/",
 "name": "websockets",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "HTTP clients and networking",
   "tools/http-clients/"
  ]
 ],
 "lead": "WebSocket implementation for Python with RFC 6455 and 7692 compliance.",
 "chips": [
  {
   "label": "HTTP clients and networking",
   "path": "tools/http-clients/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install websockets"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/python-websockets/websockets"
  },
  {
   "label": "Website",
   "href": "https://github.com/python-websockets/websockets"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "BSD-3-Clause",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI license expression.",
   "src": "https://github.com/python-websockets/websockets"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 14, 2026",
   "note": "Latest GitHub release Oct 30, 2026. ",
   "src": "https://github.com/python-websockets/websockets"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "125 projects",
   "status": "info",
   "sub": "#7 of 126 in its category",
   "note": "Dependency in 125 public GitHub projects set up for AI coding agents that we scanned (2.0%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What websockets does",
   "parts": [
    {
     "t": "prose",
     "text": "websockets is a Python library that does the WebSocket protocol and little else. It offers separate asyncio, threading, trio and Sans-I/O implementations, and its HTTP support stops at a health check."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "websockets popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "76",
       "of": "/ 100",
       "l": "Gid Score, #170 overall"
      },
      {
       "n": "131M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "5,746",
       "l": "GitHub stars"
      },
      {
       "n": "125",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How websockets is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "websockets is a dependency in 125 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (7.7% of the 1,623 Python ones), #7 of 126 in http clients and networking.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,473; those are left out of every share on this page.",
      "The most used alternative in our scan is websocket-client (18 projects).",
      "Projects that use it most often also use Uvicorn (72.0%), Pydantic (71.2%), FastAPI (66.4%).",
      "It is more common in projects set up for Roo Code (5.4%) than for OpenAI Codex (1.9%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "70 projects, 2.1%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "62 projects, 2.0%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "51 projects, 2.1%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "14 projects, 4.2%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "13 projects, 2.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "10 projects, 3.6%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "9 projects, 1.9%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "6 projects, 5.4%",
       "v": "Roo Code",
       "path": "agents/roo-code/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 72.0% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 71.2% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 66.4% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 62.4% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 56.8% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      },
      {
       "l": "In 55.2% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 50.4% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      },
      {
       "l": "In 47.2% of its projects",
       "v": "Rich",
       "path": "tools/rich/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "websockets in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "One library, three I/O styles",
       "v": "The docs show an echo server and a client for each of <code>asyncio</code>, threading and <code>trio</code>, each in its own module. The threading examples are plain blocking code with no <code>await</code>. The docs call the trio version \"functionally equivalent\" to the asyncio one."
      },
      {
       "l": "A blocking client if you skip asyncio",
       "v": "<code>websockets.sync.client.connect</code> opens a connection inside a <code>with</code> block, and you call <code>send</code> and <code>recv</code> directly. The docs call it \"a good alternative for clients, especially if you aren’t familiar with asyncio.\""
      },
      {
       "l": "CI gate at 100% branch coverage",
       "v": "The maintainers write that the library is heavily tested for compliance with RFC 6455. They also say continuous integration fails if branch coverage drops below 100%."
      },
      {
       "l": "Handshakes and pings are handled for you",
       "v": "According to the docs, the library takes care of the opening and closing handshakes, pings and pongs, and other behavior in the WebSocket specification."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Not an HTTP framework",
       "v": "The README describes its HTTP support as \"just enough for an HTTP health check.\" If you want HTTP and WebSocket in one server, it points to uvicorn or Sanic, which build on websockets."
      },
      {
       "l": "Coroutines, not callbacks",
       "v": "The README says the library was \"created to provide the best coroutine-based API.\" It tells anyone who wants callbacks to pick another library."
      },
      {
       "l": "The legacy asyncio module has an end date",
       "v": "The original <code>websockets.legacy</code> implementation was deprecated in version 14.0. The docs say it will be removed by 2030. They tell existing users to upgrade to <code>websockets.asyncio</code>, which arrived in 13.0."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Echo server with the asyncio API"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Python",
       "code": "#!/usr/bin/env python\n\nimport asyncio\nfrom websockets.asyncio.server import serve\n\nasync def echo(websocket):\n    async for message in websocket:\n        await websocket.send(message)\n\nasync def main():\n    server = await serve(echo, \"localhost\", 8765)\n    await server.serve_forever()\n\nasyncio.run(main())"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about websockets",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/python-websockets",
        "Open Collective: https://opencollective.com/websockets",
        "Tidelift: https://tidelift.com/funding/github/pypi/websockets",
        "2 GitHub sponsors"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "requests: HTTP client",
        "python-dotenv: .env config loader",
        "solders: Solana types",
        "pydantic: data validation",
        "solana: Solana Python SDK",
        "anyio: async compatibility layer"
       ]
      },
      {
       "title": "More in HTTP clients and networking",
       "path": "tools/http-clients/",
       "items": [
        {
         "text": "Axios",
         "path": "tools/axios/"
        },
        {
         "text": "Requests",
         "path": "tools/requests-py/"
        },
        {
         "text": "httpx",
         "path": "tools/httpx/"
        },
        {
         "text": "ws",
         "path": "tools/ws/"
        },
        {
         "text": "postgres",
         "path": "tools/postgres/"
        },
        {
         "text": "aiohttp",
         "path": "tools/aiohttp/"
        },
        {
         "text": "redis (Python)",
         "path": "tools/redis-pypi/"
        },
        {
         "text": "undici",
         "path": "tools/undici/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "websockets",
       "me": true,
       "facts": [
        "BSD-3-Clause",
        "Gid 76",
        "131M/wk"
       ]
      },
      {
       "name": "websocket-client",
       "why": "WebSocket client library for Python with low-level API options.",
       "path": "tools/websocket-client/",
       "facts": [
        "Apache-2.0",
        "Gid 69",
        "41.6M/wk"
       ]
      }
     ],
     "more": "Compare websockets with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install websockets"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## websockets\n- For asyncio code, import from `websockets.asyncio.server` and `websockets.asyncio.client`.\n- If a project uses `websockets.legacy`, upgrade it to `websockets.asyncio`. The docs say legacy was deprecated in 14.0 and will be removed by 2030.\n- For blocking code, use `websockets.sync.client.connect` inside a `with` block. Use `websockets.sync.server` only for servers that don't handle many client connections.\n- In Trio projects, use the `websockets.trio.server` and `websockets.trio.client` modules.\n- Don't implement handshakes, pings or pongs yourself. Call `send` and `recv`, or iterate with `async for message in websocket`.\n- Don't add HTTP routes to a websockets server. Its HTTP support only covers a health check, so use uvicorn or Sanic when one server must serve both.\n- Don't look for a callback API. The README says to pick another library if you need one.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi websockets"
  ],
  [
   "Category",
   "HTTP clients and networking"
  ],
  [
   "License",
   "BSD-3-Clause"
  ],
  [
   "Latest version",
   "17.2, October 3, 2026"
  ],
  [
   "On GitHub since",
   "March 2013"
  ],
  [
   "Gid Score",
   "76.3"
  ],
  [
   "Rank in category",
   "#7 of 126"
  ],
  [
   "GitHub",
   "python-websockets/websockets"
  ],
  [
   "Last change",
   "Nov 14, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/python-websockets.png"
}