How to use GET Request with Parameters in Python?

Published On: 10/09/2022 | Category: Python


Hi Guys,

I am going to show you example of python http get request json. you will learn python get request with query parameters. you can see python get request example. you can understand a concept of python http request example. you will do the following things for python get request with body.

Here, we will use requests library to all GET HTTP Request and get json data in python program. i will give you very simple example to call GET Request with body parameters in python.

So let's see bellow example:

Example 1: Python GET Request Example main.py
import requests
  
# GET Request API URL
url = 'https://reqres.in/api/users'
  
response = requests.get(url)
  
# GET JSON Data from API
data = response.json()
  
print(data)
Output:

Example 2: Python GET Request with Parameters Example main.py
import requests
  
# GET Request API URL
url = 'https://reqres.in/api/users'
  
# Adding Parameters
params = dict(
    page=1,
)
  
response = requests.get(url, params)
  
# GET JSON Data from API  
data = response.json()
  
print(data)
Output:

It will help you....

Happy Coding!