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
🌐
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' }
🌐
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

How can I POST JSON data with Python's Requests library? - Stack Overflow
I need to POST JSON content from a client to a server. I'm using Python 2.7.1 and simplejson. The client is using Requests. The server is CherryPy. I can GET hard-coded JSON content from the server... More on stackoverflow.com
🌐 stackoverflow.com
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
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
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
🌐
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 ...
🌐
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.
🌐
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.

Find elsewhere
🌐
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 ...
🌐
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.
🌐
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…
🌐
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
🌐
datagy
datagy.io › home › python requests › response.json() – working with json in python requests
response.json() - Working with JSON in Python requests • datagy
April 17, 2025 - 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
🌐
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.
🌐
Apidog
apidog.com › blog › python-requests-post-json
Python Requests: How to POST JSON Data with Ease in 2026
April 25, 2025 - 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.
🌐
PYnative
pynative.com › home › python › json › parse a json response using python requests library
Parse a JSON response using Python requests library
October 9, 2023 - 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.
🌐
ProxiesAPI
proxiesapi.com › articles › sending-and-receiving-json-data-with-python-requests
Sending and Receiving JSON Data with Python Requests | ProxiesAPI
September 16, 2025 - Python Requests library makes it easy to send HTTP requests and receive responses in JSON format. It simplifies working with APIs and web services.
🌐
Python Forum
python-forum.io › thread-13001.html
GET Request and JSON response
February 4, 2026 - 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...
🌐
Requests
requests.readthedocs.io › en › latest › api
Developer Interface — Requests 2.33.0.dev1 documentation
October 24, 2020 - 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.
🌐
Plain English
python.plainenglish.io › how-to-send-post-requests-with-json-data-using-python-requests-daaffa0a3335
How to Send POST Requests with JSON Data Using Python Requests? | Python in Plain English
July 23, 2025 - ✅ This gives you finer control over encoding, but for most use cases, json=... is simpler and cleaner. Suppose you’re building a Python script to send sensor data to a Flask-based API: import requests import time url = "http://localhost:5000/api/sensor" sensor_data = { "device_id": "sensor_123", "temperature": 22.5, "humidity": 60, "timestamp": int(time.time()) } response = requests.post(url, json=sensor_data) if response.ok: print("📡 Data sent successfully!") else: print("⚠️ Failed:", response.text)