Generally speaking you can introspect Python objects with the dir() and vars() functions:

>>> import requests
>>> response = requests.get('http://httpbin.org/get?foo=bar')
>>> dir(response)
['__attrs__', '__bool__', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_content', '_content_consumed', 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 'encoding', 'headers', 'history', 'is_permanent_redirect', 'is_redirect', 'iter_content', 'iter_lines', 'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url']
>>> 'url' in dir(response)
True
>>> vars(response).keys()
['cookies', '_content', 'headers', 'url', 'status_code', '_content_consumed', 'encoding', 'request', 'connection', 'elapsed', 'raw', 'reason', 'history']

You could also just use the help() function and Python will format the docstrings on a class; response.url doesn't have a docstring but is listed in the attributes section.

For requests specifically, just check out the excellent API documentation. The url attribute is listed as part of the Response object.

Answer from Martijn Pieters on Stack Overflow
Top answer
1 of 2
15

Generally speaking you can introspect Python objects with the dir() and vars() functions:

>>> import requests
>>> response = requests.get('http://httpbin.org/get?foo=bar')
>>> dir(response)
['__attrs__', '__bool__', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_content', '_content_consumed', 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 'encoding', 'headers', 'history', 'is_permanent_redirect', 'is_redirect', 'iter_content', 'iter_lines', 'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url']
>>> 'url' in dir(response)
True
>>> vars(response).keys()
['cookies', '_content', 'headers', 'url', 'status_code', '_content_consumed', 'encoding', 'request', 'connection', 'elapsed', 'raw', 'reason', 'history']

You could also just use the help() function and Python will format the docstrings on a class; response.url doesn't have a docstring but is listed in the attributes section.

For requests specifically, just check out the excellent API documentation. The url attribute is listed as part of the Response object.

2 of 2
2

Use dir() in the shell:

>>> import requests
>>> req = requests.get('http://www.google.com')
>>> dir(req)
['__attrs__', '__bool__', '__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattribute__', '__getstate__', '__hash__', '__init__',
'__iter__', '__module__', '__new__', '__nonzero__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_content', '_content_consumed',
'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 
'encoding', 'headers', 'history', 'is_redirect', 'iter_content', 'iter_lines',
'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request',
'status_code', 'text', 'url']
🌐
Python-requests
docs.python-requests.org › en › latest › api
Developer Interface — Requests 2.34.2 documentation
December 29, 2016 - Decodes the JSON response body (if any) as a Python object. This may return a dictionary, list, etc. depending on what is in the response. ... Returns the parsed header links of the response, if any. ... Returns a PreparedRequest for the next request in a redirect chain, if there is one. ... Returns True if status_code is less than 400, False if not. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error.
🌐
Pylonsproject
docs.pylonsproject.org › projects › pyramid › en › latest › api › request.html
pyramid.request — The Pyramid Web Framework v2.1
The "traversal path" will be available as the traversed attribute of the request object. It will be a sequence representing the ordered set of names that were used to traverse to the context, not including the view name or subpath. If there is a virtual root associated with the request, the virtual root path is included within the traversal path.
🌐
Pylonsproject
docs.pylonsproject.org › projects › pyramid › en › latest › narr › webob.html
Request and Response Objects — The Pyramid Web Framework v2.1
Full API documentation for the ... Pyramid adds special attributes to every request: context, registry, root, subpath, traversed, view_name, virtual_root, virtual_root_path, session, matchdict, and matched_route....
🌐
Real Python
realpython.com › python-requests
Python's Requests Library (Guide) – Real Python
July 23, 2025 - 'X-GitHub-Request-Id': 'AE83:3F40:2151C46:438A840:65C38178'} The .headers attribute returns a dictionary-like object, allowing you to access header values by key.
🌐
PyTutorial
pytutorial.com › python-requests-response-object-guide
PyTutorial | Python Requests Response Object Guide
February 11, 2026 - The raise_for_status() method is a useful shortcut. It stops your program if the request failed. Servers send metadata in headers. This includes content type, server software, and cookies. The Response object stores this in a dictionary-like structure. Access it using the .headers attribute.
🌐
Readthedocs
asks.readthedocs.io › en › latest › the-response-object.html
asks - The Response Object — asks 1.3.6 documentation
Each cookie is a Cookie object. They are pretty basic. Here’s a list of attributes: ... There may be more values set by the response. If any redirects or 401-requiring auth attempts were handled during the request, the response objects for those requests will be stored in the final response object’s .history attribute in a list.
🌐
Towards Data Science
towardsdatascience.com › home › latest › http requests in python
HTTP Requests in Python | Towards Data Science
January 27, 2025 - To summarize, in this post we discussed the basics of the python requests library. We look at the attributes and methods available to response objects. We used the text attribute to pull the html text for the home page of ‘imgur.’ We also showed how to pull one of the images on the ‘imgur’ site and save it to a file on our machine.
Find elsewhere
🌐
datagy
datagy.io › home › python requests › python requests response object explained
Python requests Response Object Explained • datagy
December 30, 2022 - We can see that when we make a request, in this case a GET request, a Response object is returned. We can see what methods and attributes are available by using the dir() function, which creates a list of attributes and methods. Let’s pass Response object into the Python dir() function:
🌐
Python
docs.python.org › 3 › library › urllib.request.html
urllib.request — Extensible library for opening URLs — Python ...
method should be a string that indicates the HTTP request method that will be used (e.g. 'HEAD'). If provided, its value is stored in the method attribute and is used by get_method(). The default is 'GET' if data is None or 'POST' otherwise. Subclasses may indicate a different default method by setting the method attribute in the class itself. ... The request will not work as expected if the data object is unable to deliver its content more than once (e.g.
🌐
GeeksforGeeks
geeksforgeeks.org › python › response-content-python-requests
response.content - Python requests - GeeksforGeeks
July 12, 2025 - When you make an HTTP request in Python using the requests library, it returns a response object. One of the most important attributes of this object is response.content, which gives you the raw response body in bytes. This is especially useful when dealing with binary data like images, PDFs, ...
🌐
GeeksforGeeks
geeksforgeeks.org › response-methods-python-requests
Response Methods - Python requests - GeeksforGeeks
July 23, 2021 - 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 ...
🌐
Beautiful Soup
tedboy.github.io › flask › generated › generated › flask.Request.html
flask.Request — Flask API
The request object is a Request subclass and provides all of the attributes Werkzeug defines plus a few Flask specific ones.
🌐
PyPI
pypi.org › project › responses
responses · PyPI
The following attributes can be passed to a Response mock: ... The HTTP method (GET, POST, etc). ... The full resource URL. ... Include the query string when matching requests. Enabled by default if the response URL contains a query string, disabled if it doesn’t or the URL is a regular expression. ... The response body. Read more Exception as Response body ... A Python object representing the JSON response body.
      » pip install responses
    
Published   May 21, 2026
Version   0.26.1
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-flask-request-object
Python Flask - Request Object - GeeksforGeeks
April 28, 2025 - This attribute allows you to specify predefined custom parameters when creating HTTP requests for your service (like "GET /info" ) which can be given as string values without any format validation etc. The cookies property contains cookie contents that will allow the client to access a piece of information about users' details through the Cookie header field of returned JSON Object ...
🌐
Scrapy
docs.scrapy.org › en › latest › topics › request-response.html
Requests and Responses — Scrapy 2.16.0 documentation
1 month ago - Third-party components may also use this attribute to decide whether to filter out a request. When defining the start URLs of a spider through start_urls, this attribute is enabled by default. See start(). attributes: tuple[str, ...] = ('url', 'headers', 'body', 'cookies', 'meta', 'encoding', 'flags', 'cb_kwargs', 'callback', 'dont_filter', 'errback', 'method', 'priority') · A tuple of str objects containing the name of all public attributes of the class that are also keyword parameters of the __init__() method.
🌐
Python-requests
fr.python-requests.org › en › latest › api.html
API — Requests 0.13.9 documentation
The core Response object. All Request objects contain a response attribute, which is an instance of this class.
🌐
W3Schools
w3schools.com › PYTHON › ref_requests_response.asp
Python requests.Response Object
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... The requests.Response() Object contains the server's response to the HTTP request.