I recommend using the awesome requests library:

import requests

url = 'http://maps.googleapis.com/maps/api/directions/json'

params = dict(
    origin='Chicago,IL',
    destination='Los+Angeles,CA',
    waypoints='Joplin,MO|Oklahoma+City,OK',
    sensor='false'
)

resp = requests.get(url=url, params=params)
data = resp.json() # Check the JSON Response Content documentation below

JSON Response Content: https://requests.readthedocs.io/en/master/user/quickstart/#json-response-content

Answer from Zach Kelling on Stack Overflow
🌐
ReqBin
reqbin.com › code › python › rituxo3j › python-requests-json-example
How do I get JSON using the Python Requests?
To request JSON data from the server using the Python Requests library, call the request.get() method and pass the target URL as a first parameter. The Python Requests Library has a built-in JSON decoder and automatically converts JSON strings ...
Discussions

Python requests module with json data some fields are binary date
Hello In Python requests module how to send json data, some fields are a binary data. And doesn’t wants to convert base64 or file as well. Do we have any other options for sending json data along with binary data by using requests module. Please let’s know if we do have any other option. Thanks More on discuss.python.org
🌐 discuss.python.org
0
March 20, 2024
python - What's the best way 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. What's the best way to coerce the More on stackoverflow.com
🌐 stackoverflow.com
Why is the json information not loading in from the request ?
I was able to connect successfully to the website. However when I use .json function why am I getting an error. Is it because I have to actually… More on reddit.com
🌐 r/learnpython
9
2
October 11, 2023
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
🌐
Real Python
realpython.com › python-requests
Python's Requests Library (Guide) – Real Python
July 23, 2025 - When you pass JSON data via json, Requests will serialize your data and add the correct Content-Type header for you.
🌐
Apify
blog.apify.com › python-post-request
How to post JSON data with Python Requests
December 7, 2025 - JSON is a lightweight data interchange format. JSON is often preferred over other formats like XML due to its simplicity and smaller payload size. This article guides you through using the requests library in Python to send a POST request with ...
🌐
ReqBin
reqbin.com › code › python › m2g4va4a › python-requests-post-json-example
How do I post JSON using the Python Requests Library?
To post a JSON to the server using Python Requests Library, call the requests.post() method and pass the target URL as the first parameter and the JSON data with the json= parameter.
🌐
Python.org
discuss.python.org › python help
Python requests module with json data some fields are binary date - Python Help - Discussions on Python.org
March 20, 2024 - Hello In Python requests module how to send json data, some fields are a binary data. And doesn’t wants to convert base64 or file as well. Do we have any other options for sending json data along with binary data by u…
Find elsewhere
🌐
Apidog
apidog.com › blog › python-requests-post-json
Python Requests: How to POST JSON Data with Ease in 2026
February 4, 2026 - In this example, we are sending an HTTP POST request to https://www.example.com/api with a JSON payload containing a username and password. The requests.post() method is used to send the request, and the response status code and content are printed to the console. You can install the requests library using the following command: ... In this blog post, we’ll be focusing on how to use Python Requests to send a POST request with JSON data.
🌐
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())
🌐
Requests
requests.readthedocs.io › en › latest › api
Developer Interface — Requests 2.33.0.dev1 documentation
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.
🌐
Reddit
reddit.com › r/learnpython › why is the json information not loading in from the request ?
r/learnpython on Reddit: Why is the json information not loading in from the request ?
October 11, 2023 - How would i simulate the download action with requests. The url I have is suppose to be the end point. If I inspect the response.text what exactly am I looking for to see how the html takes json data?
🌐
Requests
requests.readthedocs.io › en › latest › user › quickstart
Quickstart — Requests 2.33.0.dev1 documentation
>>> bad_r = requests.get('https://httpbin.org/status/404') >>> bad_r.status_code 404 >>> bad_r.raise_for_status() Traceback (most recent call last): File "requests/models.py", line 832, in raise_for_status raise http_error requests.exceptions.HTTPError: 404 Client Error · But, since our status_code for r was 200, when we call raise_for_status() we get: ... All is well. 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' }
🌐
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.
🌐
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.

🌐
Reddit
reddit.com › r/learnpython › converting response to json?
r/learnpython on Reddit: Converting Response to JSON?
October 26, 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?

🌐
W3Schools
w3schools.com › Python › module_requests.asp
Python Requests Module
The HTTP request returns a Response Object with all the response data (content, encoding, status, etc). Navigate your command line to the location of PIP, and type the following: C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install requests
🌐
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
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).