{
 "kind": "tool",
 "slug": "python-multipart",
 "path": "tools/python-multipart/",
 "name": "python-multipart",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "HTTP servers and APIs",
   "tools/http-servers/"
  ]
 ],
 "lead": "Streaming multipart parser for handling file uploads in Python web frameworks.",
 "chips": [
  {
   "label": "HTTP servers and APIs",
   "path": "tools/http-servers/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install python-multipart"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/Kludex/python-multipart"
  },
  {
   "label": "Website",
   "href": "https://github.com/Kludex/python-multipart"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Apache-2.0",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI license expression.",
   "src": "https://github.com/Kludex/python-multipart"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 22, 2026",
   "note": "Latest GitHub release Nov 16, 2026. ",
   "src": "https://github.com/Kludex/python-multipart"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "187 projects",
   "status": "info",
   "sub": "#5 of 102 in its category",
   "note": "Dependency in 187 public GitHub projects set up for AI coding agents that we scanned (3.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 python-multipart does",
   "parts": [
    {
     "t": "prose",
     "text": "python-multipart reads multipart/form-data bodies as they stream in and hands each piece to your callbacks, so an upload never has to be held whole in memory."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "python-multipart popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "67",
       "of": "/ 100",
       "l": "Gid Score, #537 overall"
      },
      {
       "n": "127M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "541",
       "l": "GitHub stars"
      },
      {
       "n": "187",
       "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 python-multipart is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "python-multipart is a dependency in 187 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (11.5% of the 1,623 Python ones), #5 of 102 in http servers and apis.",
      "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,503; those are left out of every share on this page.",
      "Projects that use it most often also use Uvicorn (95.2%), FastAPI (90.4%), Pydantic (80.7%).",
      "It is more common in projects set up for Roo Code (6.3%) than for Gemini CLI (1.5%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "94 projects, 3.1%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "93 projects, 2.8%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "73 projects, 3.0%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "10 projects, 3.0%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "9 projects, 3.2%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "8 projects, 1.7%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "7 projects, 6.3%",
       "v": "Roo Code",
       "path": "agents/roo-code/"
      },
      {
       "l": "7 projects, 1.5%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 95.2% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 90.4% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 80.7% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 63.1% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 48.7% of its projects",
       "v": "Pydantic Settings",
       "path": "tools/pydantic-settings/"
      },
      {
       "l": "In 47.1% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 45.5% of its projects",
       "v": "SQLAlchemy",
       "path": "tools/sqlalchemy/"
      },
      {
       "l": "In 41.2% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "python-multipart in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Each part is handled as its bytes arrive",
       "v": "The in-depth example reads the request in chunks and updates a SHA-256 hash inside <code>on_part_data</code>. The docs describe the goal as reaching each part \"as it arrives, without needing to store any parts in memory.\""
      },
      {
       "l": "Events, not a request object",
       "v": "You write small functions and the parser calls them. <code>on_part_begin</code> runs when a new part starts. <code>on_part_data(data, start, end)</code> passes you a buffer and the slice bounds that belong to the current part."
      },
      {
       "l": "Does not assume WSGI",
       "v": "The docs say the library \"does not assume that you are using WSGI\". The quick example therefore copies <code>CONTENT_TYPE</code> and <code>CONTENT_LENGTH</code> from the WSGI environ into a headers dict before it calls <code>parse_form</code>."
      },
      {
       "l": "Created in 2013, released again in 2026",
       "v": "The repository dates from 2013. The release notes for 0.0.32, published 2026-06-04, list one change: it replaces a per-byte partial-boundary scan with an <code>rfind</code> lookbehind."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The import name clashes with another package",
       "v": "The package used to be imported as <code>multipart</code>. The docs say that name still works, with a warning, only as long as the separate <code>multipart</code> package is not installed. If both are installed, you need to import <code>python_multipart</code>."
      },
      {
       "l": "The walkthrough carries Python 2 workarounds",
       "v": "A comment in the in-depth example says Python 2 lacks the <code>nonlocal</code> keyword, so the code sets attributes on a dummy class instead. Its sample curl output reports Python/2.7.3, with Date headers from 2013."
      },
      {
       "l": "The docs page examples use plain WSGI",
       "v": "The docs name Flask, Django and Tornado but choose to \"stick to plain WSGI\" with <code>wsgiref</code>. Both examples on the docs page run on that setup."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Feed a MultipartParser in chunks (from the in-depth example)"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Python",
       "code": "# Callbacks dictionary.\ncallbacks = { 'on_part_begin' : on_part_begin , 'on_part_data' : on_part_data , 'on_part_end' : on_part_end , }\n# Create the parser.\nparser = python_multipart . MultipartParser ( boundary , callbacks )\n# The input stream is from the WSGI environ.\ninp = environ [ 'wsgi.input' ]\n# Feed the parser with data from the request.\nsize = int ( environ [ 'CONTENT_LENGTH' ])\nwhile size > 0 :\n    to_read = min ( size , 1024 * 1024 )\n    data = inp . read ( to_read )\n    parser . write ( data )\n    size -= len ( data )\n    if len ( data ) != to_read :\n        break"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about python-multipart",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/Kludex",
        "30 GitHub sponsors"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "uvicorn: ASGI server",
        "fastapi: API framework",
        "pydantic: Data validation",
        "python-dotenv: .env file loader",
        "requests: HTTP client",
        "pydantic-settings: Settings from env vars"
       ]
      },
      {
       "title": "More in HTTP servers and APIs",
       "path": "tools/http-servers/",
       "items": [
        {
         "text": "Uvicorn",
         "path": "tools/uvicorn/"
        },
        {
         "text": "FastAPI",
         "path": "tools/fastapi/"
        },
        {
         "text": "Express",
         "path": "tools/express/"
        },
        {
         "text": "cors",
         "path": "tools/cors/"
        },
        {
         "text": "Hono",
         "path": "tools/hono/"
        },
        {
         "text": "Flask",
         "path": "tools/flask/"
        },
        {
         "text": "Starlette",
         "path": "tools/starlette/"
        },
        {
         "text": "express-rate-limit",
         "path": "tools/express-rate-limit/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "python-multipart",
       "me": true,
       "facts": [
        "Apache-2.0",
        "Gid 67",
        "127M/wk"
       ]
      }
     ],
     "more": "Compare python-multipart with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install python-multipart"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## python-multipart\n- Import it as `python_multipart`. The old `import multipart` still works, with a warning, only when the separate `multipart` package is not installed. If both are installed, you must use `python_multipart`.\n- One builder's lesson, from a FastAPI plugin host: a dependency a feature cannot work without is that feature's own requirement, so declare `python-multipart` for an upload feature rather than leaving it out to keep `pyproject.toml` tidy.\n- For whole forms, call `python_multipart.parse_form(headers, stream, on_field, on_file)`. The library does not assume WSGI, so build the headers dict with `Content-Type` and, if present, `Content-Length` yourself.\n- Check that the Content-Type is multipart/form-data before you create a parser. If it is not, skip parsing.\n- For streaming, get the boundary with `parse_options_header(content_type)` and build `MultipartParser(boundary, callbacks)` with `on_part_begin`, `on_part_data` and `on_part_end`.\n- Feed the body in chunks with `parser.write(data)`. The docs' example reads at most 1024 * 1024 bytes at a time and stops when a read comes back short. In `on_part_data`, use `data[start:end]`.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi python-multipart"
  ],
  [
   "Category",
   "HTTP servers and APIs"
  ],
  [
   "License",
   "Apache-2.0"
  ],
  [
   "Latest version",
   "0.0.32, June 4, 2026"
  ],
  [
   "On GitHub since",
   "March 2013"
  ],
  [
   "Gid Score",
   "67.2"
  ],
  [
   "Rank in category",
   "#5 of 102"
  ],
  [
   "GitHub",
   "Kludex/python-multipart"
  ],
  [
   "Last change",
   "Nov 22, 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/kludex.png"
}