Skip to content

Fix undocumented exceptions and deprecate URLRequired #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions docs/user/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.. _api:

API Reference
=============

This part of the documentation covers all the interfaces of `requests`. For parts where `requests` depends on external libraries, we document the most important right here and provide links to the canonical documentation.

Main Interface
--------------

`requests` provides two main interfaces:

- The :ref:`requests module <api-requests>`.
- The :ref:`Session class <api-session>`.

All of the requests functions and methods will return a :ref:`Response <api-response>` object. The :ref:`Response <api-response>` object contains all of the information returned by the server and will also contain the information you need.

The :ref:`Session <api-session>` object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, and will use urllib3's connection pooling. So if you're making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase (see HTTP persistent connection).

The other :ref:`Session <api-session>` feature is that it will use per-host proxies which are defined in environment variables. This is particularly useful if you are using requests from an application which does not have permission to use proxies.

.. _api-requests:

The Requests module
-------------------

.. autofunction:: requests.request
.. autofunction:: requests.get
.. autofunction:: requests.head
.. autofunction:: requests.post
.. autofunction:: requests.put
.. autofunction:: requests.patch
.. autofunction:: requests.delete
.. autofunction:: requests.options

.. _api-session:

The Session object
------------------

.. autoclass:: requests.Session
:members:
:inherited-members:
:show-inheritance:

.. _api-response:

The Response object
-------------------

.. autoclass:: requests.Response
:members:
:inherited-members:
:show-inheritance:

.. _api-exceptions:

Exceptions
----------

.. autoclass:: requests.RequestException
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.ConnectionError
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.HTTPError
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.URLRequired
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.TooManyRedirects
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.ConnectTimeout
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.ReadTimeout
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.Timeout
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.MissingSchema
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.InvalidSchema
:members:
:inherited-members:
:show-inheritance:

.. autoclass:: requests.InvalidURL
:members:
:inherited-members:
:show-inheritance:
4 changes: 0 additions & 4 deletions src/requests/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ class ReadTimeout(Timeout):
"""The server did not send any data in the allotted amount of time."""


class URLRequired(RequestException):
"""A valid URL is required to make a request."""


class TooManyRedirects(RequestException):
"""Too many redirects."""

Expand Down
Loading