API Reference

Requests

Elegant HTTP library for Python with connection pooling, sessions, and automatic content decoding.

Official Documentation ↗
CompatibilityThis documentation covers version v2.32. Check the official docs for the latest API surface.

Installation

pippip install requests

Methods

Requests is an elegant and simple HTTP library for Python, built for human beings. It is one of the most downloaded Python packages, offering a fluent API for making HTTP requests with sessions, auth, cookies, and retries.

Key Features

  • Keep-alive: Connection pooling via Session
  • JSON: Automatic encoding and decoding
  • Auth: Basic, digest, and custom auth handlers
  • Cookies: Persistent cookie jars
  • SSL: Verification and certificate options

FAQ

How do I set a timeout in Requests?
Pass timeout as a float or a (connect, read) tuple, e.g. requests.get(url, timeout=(3, 5)). Without a timeout, Requests waits indefinitely, so always set one in production code.
What is the difference between data and json?
data sends form-encoded fields or raw bytes, setting Content-Type to application/x-www-form-urlencoded. json serializes a dict to a JSON body and sets Content-Type to application/json automatically.
Does Requests support async or HTTP/2?
No. Requests is synchronous and HTTP/1.1 only. For async use httpx or aiohttp; for HTTP/2 use httpx with http2=True. Requests remains the simplest choice for blocking code.