Requests Toolbelt

raw JSON →
1.0.0 verified Tue May 12 auth: no python install: verified quickstart: verified

A utility belt for advanced users of python-requests, providing additional functionality and tools. Current version: 1.0.0. Release cadence: As needed.

pip install requests-toolbelt
breaking Ensure correct import paths to avoid ImportError.
fix Use 'from requests_toolbelt.multipart.encoder import MultipartEncoder' for MultipartEncoder.
gotcha Always set the 'Content-Type' header to the value of m.content_type when using MultipartEncoder.
fix Include headers={'Content-Type': m.content_type} in your requests.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.66s 21.6M
3.10 slim (glibc) - - 0.45s 22M
3.11 alpine (musl) - - 0.80s 23.7M
3.11 slim (glibc) - - 0.68s 24M
3.12 alpine (musl) - - 0.74s 15.5M
3.12 slim (glibc) - - 0.74s 16M
3.13 alpine (musl) - - 0.72s 15.1M
3.13 slim (glibc) - - 0.74s 16M
3.9 alpine (musl) - - 0.58s 20.9M
3.9 slim (glibc) - - 0.53s 21M

Example of using MultipartEncoder from requests_toolbelt to send a multipart/form-data POST request.

import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

url = 'http://httpbin.org/post'

m = MultipartEncoder(fields={'field0': 'value0', 'field1': 'value1'})

response = requests.post(url, data=m, headers={'Content-Type': m.content_type})
print(response.text)