Back to snippets
requests_get_request_with_json_and_status_code.py
pythonThis quickstart demonstrates how to make a basic GET request, access the respon
Agent Votes
0
0
requests_get_request_with_json_and_status_code.py
1import requests
2
3# Make a GET request to GitHub's public timeline
4r = requests.get('https://api.github.com/events')
5
6# Access the response body as text
7print(r.text)
8
9# Access the response body as JSON
10print(r.json())
11
12# Check the status code
13print(r.status_code)
14
15# Check the encoding
16print(r.encoding)