If the response is in json you could do something like (python3):

Copyimport json
import requests as reqs

# Make the HTTP request.
response = reqs.get('https://demo.ckan.org/api/3/action/group_list')

# Use the json module to load CKAN's response into a dictionary.
response_dict = json.loads(response.text)

for i in response_dict:
    print("key: ", i, "val: ", response_dict[i])

To see everything in the response you can use .__dict__:

Copyprint(response.__dict__)

Edit in May 2024 to add a suggestion on how to address if objects in the response dict is not JSON serializable.


Copyimport json
...
print(json.dumps(response.text, indent=4, sort_keys=True, default=lambda o:'<not serializable>'))
Answer from Jortega on Stack Overflow
🌐
Real Python
realpython.com › python-requests
Python's Requests Library (Guide) – Real Python
July 23, 2025 - The type of the return value of .json() is a dictionary, so you can access values in the object by key: ... You can do a lot with status codes and message bodies. But if you need more information, like metadata about the response itself, you’ll need to look at the response’s headers. The response headers can give you useful information, such as the content type of the response payload and how long to cache the response. To view these headers, access .headers: ... >>> import requests >>> response = requests.get("https://api.github.com") >>> response.headers {'Server': 'github.com', ...
🌐
ReqBin
reqbin.com › code › python › wr2wzoxh › python-requests-response-example
How do I get the response object in Python Requests?
Requests Library is a most popular Library that makes it straightforward to send HTTP requests using POST, GET and PUT methods, post JSON and XML data, upload files, and submit HTML forms. The Library automatically validates server SSL certificates and supports session cookies and International Domain Names. The Requests Library is established on the urllib3 library and disguises the complexness of making HTTP requests behind a simple API. The Requests Library is not contained in the Python distribution, almost everyone uses Requests Library because the Python code for working with HTTP becomes simple, short, and straightforward.
🌐
W3Schools
w3schools.com › python › ref_requests_get.asp
Python Requests get Method
Python Examples Python Compiler ... Study Plan Python Interview Q&A Python Bootcamp Python Training ... The get() method sends a GET request to the specified url. ... The get() method returns a requests.Response object....
🌐
Codecademy
codecademy.com › docs › python › requests module › .get()
Python | Requests Module | .get() | Codecademy
May 15, 2024 - The .get() method sends a request for data to a web server. The response object it returns contains various types of data such as the webpage text, status code, and the reason for that response.
Top answer
1 of 1
7

They are both correct and will work the same.

The best way to clear up this confusion is to look at the requests source code.

Here is the code for request.get (as of 2.25.1):

def get(url, params=None, **kwargs):
    r"""Sends a GET request.
    :param url: URL for the new :class:`Request` object.
    :param params: (optional) Dictionary, list of tuples or bytes to send
        in the query string for the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :return: :class:`Response <Response>` object
    :rtype: requests.Response
    """

    kwargs.setdefault('allow_redirects', True)
    return request('get', url, params=params, **kwargs)

...which shows that requests.get just calls requests.request with a hardcoded 'get' for the 1st argument. All the other parameters (url, params, **kwargs) are all just passed through.

Basically, it is just a convenience method or a shorthand or a shortcut so you don't have to manually remember which string to pass for the method parameter. It's easier especially when using an IDE because your IDE's IntelliSense can help you select .get or .post or .delete, etc. but not the raw strings "GET", "POST", or "DELETE", etc.

The requests docs can also offer some clarity.

  • requests.request(method, url, **kwargs)

    It says "Constructs and sends a Request.". So this one is for ANY type of request, and you need to pass in 2 required arguments: the method and the URL. All the possible kwargs are listed in the doc, including the params from your example.

  • requests.get(url, params=None, **kwargs)

    It says "Sends a GET request.". So this one is more specific in that it is only for a GET request. It only has 1 required argument, the URL. No need to pass "GET". And then kwargs is "Optional arguments that request takes." which just points back to the main requests.request method.

I would say it's a matter of opinion and coding style which one to use. A use-case where it makes sense to prefer requests.request is when wrapping different API calls and providing a Python interface for them.

For example, I have these APIs:

  • GET /api/v1/user/[user-id]
  • PATCH /api/v1/user/[user-id]
  • DELETE /api/v1/user/[user-id]

When implementing get_user and update_user and delete_user, I could just call the .get, .post, .delete, etc. methods. But if calling these APIs required passing in many and/or complicated kwargs (headers, auth, timeout, etc.), then that would lead to a lot of duplicated code.

Instead, you can do it all in one method then use requests.request:

def get_user(user_id):
    return call_api("GET", user_id)

def update_user(user_id, user):
    return call_api("PATCH", user_id, user=user)

def delete_user(user_id):
    return call_api("DELETE", user_id)

def call_api(method, user_id, user=None):
    # Lots of preparation code to make a request
    headers = {
        "header1": "value1",
        "header2": "value2",
        # There can be lots of headers...
        "headerN": "valueN",
    }
    timeout = (1, 30)
    payload = user.json() if user else {}

    url = f"/api/v1/user/{user_id}"
    return requests.request(
        method,
        url,
        headers=headers,
        timeout=timeout,
        json=payload,
    )

There are probably other ways to refactor the code above to reduce duplication. That's just an example, where if you called .get, .patch, .delete directly, then you might end up repeating listing all those headers every time, setting up the URL, doing validations, etc.

Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › response-methods-python-requests
Response Methods - Python requests - GeeksforGeeks
July 12, 2025 - When one makes a request to a URI, it returns a response. This Response object in terms of python is returned by requests.method(), method being - get, post, put, etc. Response is a powerful object with lots of functions and attributes that assist in normalizing data or creating ideal portions ...
🌐
PyTutorial
pytutorial.com › python-requests-response-object-guide
PyTutorial | Python Requests Response Object Guide
February 11, 2026 - For a deeper dive into how Python objects work, see our Python Objects: Classes, Instances, and Methods Guide. Let's start with a basic example. We will fetch data from a public API. This will give us a Response object to examine. import requests # Make a GET request to a test API response = requests.get('https://jsonplaceholder.typicode.com/posts/1') # Now, 'response' is our Response object print(type(response))
🌐
Oxylabs
oxylabs.io › blog › python-requests
Python Requests Library: 2026 Guide
In the preceding example, we define ... using the headers argument. The get() method. If the request is successful (a 200 status code is given), we use the response.json() function to convert the JSON data returned by the API into a Python object....
🌐
W3Schools
w3schools.com › python › ref_requests_response.asp
Python requests.Response Object
Python Examples Python Compiler ... Q&A Python Bootcamp Python Training ... The requests.Response() Object contains the server's response to the HTTP request....
🌐
Stack Overflow
stackoverflow.com › questions › 70554533 › how-to-get-the-data-out-of-requests-response-object-in-python
How to get the data out of `requests.Response` object in Python? - Stack Overflow
The dydx3.helpers.requests.Response object only has 2 attributes: headers which contains the HTTP headers of the response from the API · data which contains a dict either empty or containing the json data returned by the API. So all you have to do in your code to get the data is:
🌐
Requests
requests.readthedocs.io › en › latest › user › advanced
Advanced Usage — Requests 2.34.2 documentation
The Response object contains all of the information returned by the server and also contains the Request object you created originally. Here is a simple request to get some very important information from Wikipedia’s servers: >>> r = requests.get('https://en.wikipedia.org/wiki/Monty_Python') If we want to access the headers the server sent back to us, we do this: >>> r.headers {'content-length': '56170', 'x-content-type-options': 'nosniff', 'x-cache': 'HIT from cp1006.eqiad.wmnet, MISS from cp1010.eqiad.wmnet', 'content-encoding': 'gzip', 'age': '3080', 'content-language': 'en', 'vary': 'Acc
Top answer
1 of 2
1

It looks to me from the source code for the ProxyError exception object in Requests like that object should have the request in it. I know you said you think it doesn't, but this shows that it is at least putting a response field in there, even if it were to end up null.

I would have maybe put this in comments, but you can't format code there. This sure seems though like it would give you what you want:

class RequestException(IOError):
    """There was an ambiguous exception that occurred while handling your
    request.
    """

    def __init__(self, *args, **kwargs):
        """Initialize RequestException with `request` and `response` objects."""
        response = kwargs.pop('response', None)
        self.response = response
        self.request = kwargs.pop('request', None)
        if (response is not None and not self.request and
                hasattr(response, 'request')):
            self.request = self.response.request
        super(RequestException, self).__init__(*args, **kwargs)

class ConnectionError(RequestException):
    """A Connection error occurred."""

class ProxyError(ConnectionError):
    """A proxy error occurred."""

So seeing this code, it seems like something like this would work:

try:
    ...
    session.get(url=url, headers=req_headers, verify=False, allow_redirects=True, timeout=30)
    ...
except ProxyError as ex:
    the_response = ex.response
    .. do something with the response ..
2 of 2
0

I think you may be able to use Request's history functionality to access that object, and Request's standard APIs to go from there:

https://2.python-requests.org//en/latest/user/quickstart/#redirection-and-history

By default Requests will perform location redirection for all verbs except HEAD.

We can use the history property of the Response object to track redirection.

The Response.history list contains the Response objects that were created in order to complete the request. The list is sorted from the oldest to the most recent response.

r = requests.get('http://github.com/')

r.url 'https://github.com/'

r.status_code 200

r.history [<Response [301]>]

Will headers then not give you what you need?

https://2.python-requests.org//en/latest/user/advanced/#advanced

>>> r.headers
{'content-length': '56170', 'x-content-type-options': 'nosniff', 'x-cache':
'HIT from cp1006.eqiad.wmnet, MISS from cp1010.eqiad.wmnet', 'content-encoding':
'gzip', 'age': '3080', 'content-language': 'en', 'vary': 'Accept-Encoding,Cookie',
'server': 'Apache', 'last-modified': 'Wed, 13 Jun 2012 01:33:50 GMT',
'connection': 'close', 'cache-control': 'private, s-maxage=0, max-age=0,
must-revalidate', 'date': 'Thu, 14 Jun 2012 12:59:39 GMT', 'content-type':
'text/html; charset=UTF-8', 'x-cache-lookup': 'HIT from cp1006.eqiad.wmnet:3128,
MISS from cp1010.eqiad.wmnet:80'}
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-requests-tutorial
Python Requests - GeeksforGeeks
July 31, 2025 - To install requests library via pip, use the following command: ... **kwargs: Additional optional arguments such as headers, cookies, authentication, timeout, proxies, verify (SSL), stream, etc. Return Type: It returns a response object. Let's try making a get request to URL: "https://www....
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.34.2 documentation
1 month ago - That’s all well and good, but it’s also only the start of what Requests can do. You often want to send some sort of data in the URL’s query string. If you were constructing the URL by hand, this data would be given as key/value pairs in the URL after a question mark, e.g. httpbin.org/get?key=val.
🌐
Stack Overflow
stackoverflow.com › questions › 71629612 › how-to-make-fetch-request-and-get-data-from-object-in-python
How to make fetch request and get data from object in python? - Stack Overflow
You get a json string, then convert that to json, then search for the bit that you want. import requests import json response_API = requests.get('https://newsapi.org/v2/top-headlines?q=sports&country=ru&pageSize=10&apiKey=befce9fd53c04bb695...