Load it via json.load():

import json
response = urllib.request.urlopen(req)
result = json.loads(response.readall().decode('utf-8'))
message_id = result['messages'][0]['message-id']
Answer from alecxe on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › python requests, response.json() returning string object instead of dict.
r/learnpython on Reddit: Python Requests, response.json() returning string object instead of dict.
December 8, 2021 -

Hi,

I was under the impression that the using .json() to a request made with Python requests, would yield a dictionary object, but it seems I am getting back a string object.
Am I missing a step?

Here is the code:

def otc_holdings():

    SIZE = 1

    url = 'https://www.otcmarkets.com/research/stock-screener/api'


    params = {'securityType' : 'Common Stock,ADRs',
              'page':1, 'pageSize': SIZE}


    from requests.models import PreparedRequest
    req = PreparedRequest()
    req.prepare_url(url, params)
    print(req.url)


    response =requests.get(url,headers = \
                           USER_AGENTS.random_header(),
                           params= params).json()


    print(response)

    print(type(response))


    print(response['pages'])


    assert response['pages'] == '1'
Discussions

python - How to convert request.data to dict? - Stack Overflow
I try to get JSON data from client using this line (requests library) POST request: request.data How to convert this to dict? It works: response_data = request.get_json() But how convert this to... More on stackoverflow.com
🌐 stackoverflow.com
python - How to parse a JSON response from the requests library - Stack Overflow
I'm using the Python requests module to send a RESTful GET to a server, for which I get a response in JSON. The JSON response is basically just a list of lists. How can I coerce the response to a n... More on stackoverflow.com
🌐 stackoverflow.com
python - Convert response.request.body to dict - Stack Overflow
Using the python requests library I can issue a POST: Copyresponse = requests.post("https://httpbin.org", data = {"x": 100, "y": 200}) The returned requests.Response object still holds a reference to the original request. More on stackoverflow.com
🌐 stackoverflow.com
Converting Requests response to JSON or dictionary, please help!
Is that response.txt format you posted complete copy paste? If so it isn't valid JSON. It doesn't even have a closing } More on reddit.com
🌐 r/learnpython
4
1
April 20, 2021
🌐
datagy
datagy.io › home › python requests › response.json() – working with json in python requests
response.json() - Working with JSON in Python requests • datagy
December 30, 2022 - Whenever the requests library is used to make a request, a Response object is returned. The Python requests library provides a helpful method, json(), to convert a Response object to a Python dictionary.
🌐
W3Schools
w3schools.com › python › ref_requests_response.asp
Python requests.Response Object
Python Examples Python Compiler ... Python Bootcamp Python Training ... The requests.Response() Object contains the server's response to the HTTP request....
🌐
Requests
requests.readthedocs.io › en › latest › api
Developer Interface — Requests 2.34.2 documentation
requests.request(method: str, url: _t.UriType, **kwargs: Unpack[_t.RequestKwargs]) → Response[source]¶ · Constructs and sends a Request. ... params – (optional) Dictionary, list of tuples or bytes to send in the query string for the Request. data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request. json – (optional) A JSON serializable Python object to send in the body of the Request.
Find elsewhere
🌐
Python-requests
docs.python-requests.org › en › latest › api
Developer Interface — Requests 2.34.2 documentation
December 29, 2016 - Sends a HEAD request. Returns Response object. ... A case-insensitive dictionary of headers to be sent on each Request sent from this Session.
🌐
Reddit
reddit.com › r/learnpython › converting requests response to json or dictionary, please help!
r/learnpython on Reddit: Converting Requests response to JSON or dictionary, please help!
April 20, 2021 -

I have a program that is taking data from two APIs (both from rapidapi) and I was able to get the first one's response to convert to json so that I could take just the value for one key with no problems. But the second response will absolutely not do so. Here is an example of how the response.text is formatted:

{"imdbID":"tt2375844","tmdbID":"334742","imdbRating":24,"imdbVoteCount":285,"tmdbRating":33,"backdropPath":"/jL0osb1ddQ25mjbTTVYhXuNtMfw.jpg","backd
ropURLs":{"1280":"https://image.tmdb.org/t/p/w1280/jL0osb1ddQ25mjbTTVYhXuNtMfw.jpg","300":"https://image.tmdb.org/t/p/w300/jL0osb1ddQ25mjbTTVYhXuNtM
fw.jpg","780":"https://image.tmdb.org/t/p/w780/jL0osb1ddQ25mjbTTVYhXuNtMfw.jpg","original":"https://image.tmdb.org/t/p/original/jL0osb1ddQ25mjbTTVYh
XuNtMfw.jpg"},"originalTitle":"Fractured","genres":[18,27,53],"countries":[],"year":2015,"runtime":89,"cast":["Eric Roberts","Jake Busey","Shena Adl
","Athena Isabel Lebessis"],"significants":["Lance Kawas"],"title":"Fractured","overview":"May Oster, played by Athena Lebessis, is a beautiful,

And so on. Here is the code that I'm trying to finish:

for id in imdb_ids:
    querystring = {"country":"us","imdb_id":id}
    streamresponse = requests.request("GET", url, headers=headers, params=querystring)

Up to this point, it works fine. But converting it is impossible. I've tried streamresponse.json(), json.loads(streamresponse), ast.literal_eval(streamresponse), and a few other things. Every time I try to convert to json I get a bunch of errors with the main one being json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0). I think this means that the response.text is not formatted like json, but, from what I can tell, it is.

I just want to take just certain information from the response.text (like "title") so if anyone can give me some pointers, I would really appreciate it.

🌐
GeeksforGeeks
geeksforgeeks.org › python › response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 12, 2025 - In this article, we will explore how to use response.json() to load JSON data into Python objects. In the below code, firstly we imported the requests module and then fetch the data from an API using requests.get() method and store in variable 'response'. When we print the response it prints '<Response [200]>' which is the HTTP code that indicates success. To print the JSON data fetched we have used json() method which prints the JSON data in the Python dictionary format as seen in the output.
🌐
Nitratine
nitratine.net › blog › post › python-requests-tutorial
Python Requests Tutorial - Nitratine
April 4, 2019 - If a site returns a JSON response, you can call .json() on the Response object to convert the JSON object in the response to a Python dictionary. import requests request = requests.get('https://jsonplaceholder.typicode.com/todos/1') data = ...
🌐
Python-requests
docs.python-requests.org › en › v1.1.0 › api
https://docs.python-requests.org/en/v1.1.0/api/
Registers a connection adapter to a prefix. ... Sends a OPTIONS request. Returns Response object. ... Dictionary of querystring data to attach to each Request.
🌐
Scrapy
docs.scrapy.org › en › latest › topics › request-response.html
Requests and Responses — Scrapy 2.16.0 documentation
1 month ago - A dictionary that contains arbitrary metadata for this request. Its contents will be passed to the Request’s callback as keyword arguments. It is empty for new Requests, which means by default callbacks only get a Response object as argument.
🌐
PYnative
pynative.com › home › python › json › parse a json response using python requests library
Parse a JSON response using Python requests library
May 14, 2021 - The requests module provides a builtin JSON decoder, we can use it when we are dealing with JSON data. Just execute response.json(), and that’s it. response.json() returns a JSON response in Python dictionary format so we can access JSON using ...
🌐
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', ...