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 - 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.
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
The JSON response is essentially a list of lists. What’s the best way to convert the response into a native Python object so I can easily iterate over it or print it out using print? Can you help me understand how to properly handle the Python response JSON? More on community.testmuai.com
🌐 community.testmuai.com
0
November 10, 2024
Parse youtube json response with python

Assuming this is stored in a variable named json_str, try:

import json
yto = json.loads(json_str)
print(yto['kind'])
More on reddit.com
🌐 r/learnpython
3
0
November 20, 2018
Please help - how to view JSON response from API after Python request? Banging my head against a wall!
Post the actual code? More on reddit.com
🌐 r/learnpython
10
6
October 30, 2016
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.33.0.dev1 documentation
We can view the server’s response headers using a Python dictionary: >>> r.headers { 'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'connection': 'close', 'server': 'nginx/1.0.4', 'x-runtime': '148ms', 'etag': '"e1ca502697e5c9317743dc078f67693f"', 'content-type': 'application/json' }
🌐
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?

🌐
Bright Data
brightdata.com › faqs › json › extract-json-response-python
How to Extract Data from a JSON Response in Python?
April 17, 2025 - Learn how to extract data from a JSON response in Python with this guide. Master JSON parsing for efficient data extraction in web scraping and API interactions.
🌐
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 - Learn how to parse JSON response using the requests library. Access data from JSON response directly using a key. Access Nested JSON key directly from response.
Find elsewhere
🌐
ProxiesAPI
proxiesapi.com › articles › parsing-json-responses-from-apis-in-python-requests
Parsing JSON Responses from APIs in Python Requests | ProxiesAPI
import requests response = requests.get('https://api.example.com/data') data = response.json() print(data['key1']) This automatically parses the JSON and returns a Python dict that you can access just like any other dict.
🌐
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.
🌐
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': 30 } response = requests.post('https://api.example.com/users', json=data)
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - Learn how to work with JSON data in Python using the json module. Convert, read, write, and validate JSON files and handle JSON data for APIs and storage.
🌐
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...
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
JSON is text, written with JavaScript object notation. Python has a built-in package called json, which can be used to work with JSON data.
🌐
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…
🌐
OpenAI
platform.openai.com › docs › guides › structured-outputs
Structured model outputs | OpenAI API
Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied JSON Schema, so you don’t need to worry about the model omitting a required key, or hallucinating an invalid enum value. ... In addition to supporting JSON Schema in the REST API, the OpenAI SDKs for Python and JavaScript also make it easy to define object schemas using Pydantic and Zod respectively.
🌐
Apidog
apidog.com › blog › python-requests-post-json
Python Requests: How to POST JSON Data with Ease in 2026
February 4, 2026 - When you use the json parameter, Python Requests automatically converts your Python dictionary into a JSON string and sets the correct Content-Type header (application/json). This eliminates the need to manually serialize the data using ...
🌐
Schulich School of Engineering
schulich.libguides.com › c.php
Parsing JSON Responses in Python - Getting Started With APIs - SSE Tech Support at Schulich School of Engineering - University of Calgary
July 30, 2024 - This module allows us to parse JSON-formatted strings into Python data structures (such as dictionaries and lists) and vice versa. The following example demonstrates what an unparsed JSON response looks like, which will hopefully get you to appreciate the importance of parsing for readability purposes.
🌐
Python
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
3 weeks ago - If the data being deserialized is not a valid JSON document, a JSONDecodeError will be raised. Changed in version 3.6: All parameters are now keyword-only. ... Return the Python representation of s (a str instance containing a JSON document).
🌐
Medium
medium.com › @aarav.gupta9 › a-comprehensive-guide-to-json-with-python-api-172be340e7c0
A Comprehensive Guide to JSON with Python API | by Aarav Gupta | Medium
December 14, 2023 - Many APIs use JSON as their data format, making it a popular choice for data exchange. Python’s requests library simplifies the process of making HTTP requests to APIs. Here’s a basic example of how to make a GET request to an API and parse the JSON response:
🌐
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 - After applying the .json() method to a response created by the requests library, we created a dictionary. This means that we can access the data in the dictionary using common dictionary methods, such as square-bracket indexing or the .get() method. Let’s see how we can access the 'page' key in the data: # Accessing Data in a Python Request Response import requests resp = requests.get('https://reqres.in/api/users') resp_dict = resp.json() print(resp_dict.get('page')) # Returns: 1