Send GET request to URL
requests.get('https://api.github.com/events')
Send POST request with some form data
requests.post('https://httpbin.org/post', data={'key': 'value'})
Send GET request with URL query parameters
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get('https://httpbin.org/get', params=payload)
# https://httpbin.org/get?key2=value2&key1=value1Send GET request with custom User-Agent header
r = requests.get(url, headers={'user-agent': 'my-app/0.0.1'})Send POST request with JSON payload
r = requests.post(url, json={
"name": "test",
"value": 123,
})
Response: get decoded response string
r.text
Response: get response JSON
r.json()
Response: get status code
r.status_code