Home

Requests

Requests are messages sent by a client to a server to obtain a resource or instruct the server to perform an action. The most common protocol for web requests is HTTP. An HTTP request consists of a request line with a method, a request-target (URL), and the HTTP version; followed by headers, a blank line, and an optional body. Methods indicate the action; GET retrieves data, POST submits data, PUT and PATCH modify resources, DELETE removes them, while HEAD and OPTIONS query metadata. Requests include a Host header and may carry authentication tokens, content types, and other metadata. The body is used when sending data, such as form submissions or JSON.

Upon receiving a request, a server responds with a status code, a reason phrase, and response headers,

The requests library is a popular open-source HTTP client for Python. The library offers a high-level API

Related concepts include client-side request APIs in web browsers, such as the Fetch API and XMLHttpRequest

plus
an
optional
body.
Status
codes
are
grouped
into
classes:
1xx
informational,
2xx
success,
3xx
redirection,
4xx
client
errors,
and
5xx
server
errors.
Headers
convey
metadata
such
as
content
type,
length,
caching
directives,
and
authentication
status.
HTTPS,
HTTP
over
TLS,
provides
encryption
and
integrity
protections
for
requests
and
responses.
with
functions
like
requests.get,
requests.post,
and
requests.put,
and
supports
sessions,
cookies,
redirects,
streaming
responses,
timeouts,
and
automatic
handling
of
JSON
data.
It
aims
to
be
concise
and
human-friendly
and
builds
on
lower-level
libraries
such
as
urllib3.
Requests
is
commonly
used
for
interacting
with
web
services,
APIs,
and
web
scraping,
when
allowed
by
terms
of
service
and
robots.txt.
in
JavaScript,
and
other
language-specific
HTTP
clients.
Understanding
requests
involves
considerations
of
security
(TLS,
authentication),
performance
(connection
pooling,
streaming),
and
correctness
(idempotence,
proper
method
usage).