Since you're using requests, you should use the response's json method.

import requests

response = requests.get(...)
data = response.json()

It autodetects which decoder to use.

Answer from pswaminathan on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 12, 2025 - 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. In this way, we can pas parse JSON responses in Python. ... # import requests module import requests # Making a get request response = requests.get('https://api.github.com///') # print response print(response) # print json content print(response.json())
Discussions

Converting Response to JSON?
You don't want to convert it to json format; that would give you a string for storing the data (or sending over the wire). The message is telling you that you are indexing a list as if it was a dict. You know that data is a list so "data['value']" won't work but "data[i]" might... but you don't really need to use the indexes given by range, you want the contents of the list. Only use range when you want to do arithmetic with the indexes. I am guessing this will work as well and be a bit simpler. for val in data: for item in val['value_i_want']: print(item) More on reddit.com
🌐 r/learnpython
7
3
October 24, 2020
How to Parse JSON Response in Python? - TestMu AI Community
What’s the Best Way to Parse a JSON Response from the Requests Library in Python? I’m using the Python requests module to send a RESTful GET request to a server, which returns a response in JSON format. The JSON response is essentially a list of lists. What’s the best way to convert the ... More on community.testmuai.com
🌐 community.testmuai.com
0
November 10, 2024
[Python] How to parse JSon response from a post request (Requests)
If I run your code I get NameError on session, maybe you need to define that for it to work? More on reddit.com
🌐 r/learnprogramming
9
2
March 2, 2017
Help With Python, API GET Requests, and JSON
So requests.get() returns a requests.models.Response object, not the raw JSON data. In order to access the raw text that you are seeing when you visit that URL in your browser, you would need to call response.text. That being said, the requests library has a built-in JSON decoder so you don't actually even need to use the json library. You can just do data = response.json() and that will yield a dict object that is JSON decoded from the response text. More on reddit.com
🌐 r/learnpython
2
2
April 26, 2018
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.33.0.dev1 documentation
Some servers may return a JSON ... 500). Such JSON will be decoded and returned. To check that a request is successful, use r.raise_for_status() or check r.status_code is what you expect. In the rare case that you’d like to get the raw socket response from the server, ...
🌐
Python Forum
python-forum.io › thread-13001.html
GET Request and JSON response
Good morning I'm trying to use Python to connect to a MySQL Database, so I'm trying to use a GET request and a PHP script. The code I have so far is: import requests import json print 'Hello, World' url = 'https://www.thebar.inthepub.co.uk/restt...
🌐
Reddit
reddit.com › r/learnpython › converting response to json?
r/learnpython on Reddit: Converting Response to JSON?
October 24, 2020 -

Hi all, im trying to grab some data from a website using the requests module in Python. Here is what I have:

import requests, json

apiEndpoint = 'website.com'

r = requests.post(url = apiEndpoint)

data = r.json()

When I do a print(type(r)) I get <class 'requests.models.Response'>

When I do a print(type(data)) I get <class 'list'>

When I want to iterate through the values of data, I am getting an error.

for i in range(len(data['value'])):

for item in data['value'][i]['value_i_want']:
do something
The error I am receiving is:

"TypeError: list indices must be integers or slices, not str"

So it converted the response into a list, when I want it to convert into JSON so I can access the data easily. Any ideas?

🌐
ProxiesAPI
proxiesapi.com › articles › sending-and-receiving-json-data-with-python-requests
Sending and Receiving JSON Data with Python Requests | ProxiesAPI
To send JSON data in a POST or PUT request, simply pass a Python dict to the · json parameter. Requests will serialize the dict to JSON and add the correct Content-Type header for you: ... import requests data = { 'name': 'John Doe', 'age': ...
🌐
TestMu AI Community
community.testmuai.com › ask a question
How to Parse JSON Response in Python? - TestMu AI Community
November 10, 2024 - What’s the Best Way to Parse a JSON Response from the Requests Library in Python? I’m using the Python requests module to send a RESTful GET request to a server, which returns a response in JSON format. The JSON respons…
Find elsewhere
🌐
Medium
medium.com › @themathlab › api-requests-json-parsing-in-python-a-guide-in-data-collection-31e985981ea3
API Requests & JSON Parsing in Python: A Guide in Data Collection | by The Math Lab | Medium
April 2, 2025 - Therefore it is clear that we need to convert JSON string into a usable data structure for easier manipulation and access within the program. This process is called JSON parsing. In Python, we can convert JSON string into a Python dictionary.
🌐
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 ... response.json(), and that’s it. response.json() returns a JSON response in Python dictionary format so we can access JSON using key-value pairs....
🌐
ReqBin
reqbin.com › code › python › m2g4va4a › python-requests-post-json-example
How do I post JSON using the Python Requests Library?
The Requests Library supports SSL connections, international domain names, and session cookies. It automatically encodes POST data, formats JSON, decompresses server responses, and has built-in ...
🌐
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 ... Certificate Python Training ... The requests.Response() Object contains the server's response to the HTTP request....
🌐
Bright Data
brightdata.com › faqs › json › extract-json-response-python
How to Extract Data from a JSON Response in Python?
April 17, 2025 - For example, let’s fetch data from a sample API. Once you have the response, you can parse the JSON content using the json library. With the JSON data parsed into a Python dictionary, you can extract specific values.
🌐
Apify
blog.apify.com › python-post-request
How to post JSON data with Python Requests
December 7, 2025 - Accessing content: Access the response content using the text or json methods of the Response object. Error handling: Wrap your POST request code in a try-except block to handle potential errors.
🌐
Reddit
reddit.com › r/learnpython › help with python, api get requests, and json
r/learnpython on Reddit: Help With Python, API GET Requests, and JSON
April 26, 2018 -

Hello, I am very new to Python and am trying to use Python to grab a JSON file from an API in order to extract data. I believe I have done the string concatenation properly, with the URL and Artist values I have created. If you visit the URL here you are able to see the JSON text correctly. However, I am trying to store this data in an object, however it does not seem to be working for some reason. Printing should yield the JSON text, but it does not.

Here is my code and the error I get when trying to run it. I'm really stumped at the moment because a lot of the tutorials I've seen seem to show these steps working fine.

🌐
PyPI
pypi.org › project › requests
requests · PyPI
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   Aug 18, 2025
Version   2.32.5
🌐
Python.org
discuss.python.org › python help
Question about json.loads() - Python Help - Discussions on Python.org
June 12, 2020 - Hi, I am trying to get the content to print as a python list. But it says json.loads(page) needs to be a string? When I use pythonlist = page.json() it works. Why is that? Should I never use json.loads() and always use .json()? page = requests.get(“https://api.datamuse.com/words?ml=ringing+in+the+ears”) pythonlist = json.loads(page) print(pythonlist)
🌐
ReqBin
reqbin.com › code › python › rituxo3j › python-requests-json-example
How do I get JSON using the Python Requests?
In this Python GET JSON example, we send a GET request to the ReqBin echo URL and receive JSON data in the response. The custom 'Accept: application/json' header tells the server that the client expects a JSON.
🌐
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
...as description and tax are optional ... you created, Item. With just that Python type declaration, FastAPI will: Read the body of the request as JSON....