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
๐ŸŒ
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....
Discussions

How do I read a response from Python Requests? - Stack Overflow
I have two Python scripts. One uses the Urllib2 library and one uses the Requests library. I have found Requests easier to implement, but I can't find an equivalent for urlib2's read() function. For More on stackoverflow.com
๐ŸŒ stackoverflow.com
What is the proper way of using python requests, `requests.request("GET",...)` or`requests.get`? - Stack Overflow
I'm learning Python requests through a book I purchased. From the book and from the websites I researched, it states this is the proper way to perform a GET request. requests.get(url, params={key: ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Best way to parse get request response into class objects?
You're looking for deserialization libraries. That a look at attrs or Pydantic More on reddit.com
๐ŸŒ r/learnpython
1
1
February 9, 2022
How to get the data out of `requests.Response` object in Python? - Stack Overflow
I am downloading data from the cryptocurrency exchange dydx. The example URL of REST API endpoint that I am dealing with is https://api.dydx.exchange/v3/historical-funding/BTC-USD (You can check ou... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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.
๐ŸŒ
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_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....
Find elsewhere
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.

๐ŸŒ
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....
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_requests_get_method.htm
Python Requests get() Method
The Python Requests get() method is used to send an HTTP GET request to a specified URL. This method retrieves data from the specified server endpoint. This method can accept optional parameters such as params for query parameters, headers for ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ best way to parse get request response into class objects?
r/learnpython on Reddit: Best way to parse get request response into class objects?
February 9, 2022 -

Hi r/learnpython,

As part of my learning I have been trying to incorporate more object oriented design to my code where appropriate. I am currently writing a script that makes get requests to a service, and to me it seems like the ideal place to use a custom class. Only I am not sure the best way to go about it.

Say I make a get request to a service that returns a list of objects representing people such as {โ€œnameโ€: โ€œfooโ€, โ€œDOBโ€: โ€œ90/09/21โ€, โ€œheightโ€: 182.1}. Typically I would get and parse the response like so: requests.get(url, params=params, headers=headers).json(). If successful, this object will be a list of dictionaries where each dictionary represents a person. In this case it is safe to assume that each person dictionary will follow the same schema. So to me it makes sense to have a class Person, and rather than have a list of dictionaries, instead have a list of Person objects.

The obvious way to do this it seems is to loop through the json response and convert each dictionary to a Person object. This approach feels a little โ€˜clunkyโ€™ to me, so I was wondering if there is a cleaner way to parse a response into a list of class objects? Perhaps a response method similar to json() except you pass the desired class as an argument (I donโ€™t know if such a thing exists)?

Also if you think that my approach of wanting to parse my response straight to class objects is a bad approach I would very much like to hear that too. I struggle to find any documentation on this online, so maybe there is a reason not to do what I am trying to do? Maybe there is a better way to design this? Any feedback is very welcome, it is all part of the learning process.

Thank you,
u/Smart_Peanut_3640

๐ŸŒ
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:
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'}
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ requests
requests ยท PyPI
1 month ago - Python HTTP for Humans. ... Requests is a simple, yet elegant, HTTP library. >>> import requests >>> r = requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass')) >>> r.status_code 200 >>> r.headers['content-type'] 'application/json; charset=utf8' >>> r.encoding 'utf-8' >>> r.text '{"authenticated": true, ...' >>> r.json() {'authenticated': True, ...}
      ยป pip install requests
    
Published ย  May 14, 2026
Version ย  2.34.2