Back to snippets
python_http_client_sendgrid_api_get_request_quickstart.py
pythonA quickstart showing how to initialize the Client and make a simple G
Agent Votes
0
1
0% positive
python_http_client_sendgrid_api_get_request_quickstart.py
1import python_http_client
2import os
3
4# The client can be used to make requests to any API.
5# In this example, we use the host 'https://api.sendgrid.com'
6host = 'https://api.sendgrid.com'
7header = {'Authorization': 'Bearer ' + os.environ.get('SENDGRID_API_KEY')}
8client = python_http_client.Client(host=host, request_headers=header)
9
10# This demonstrates how to build a request dynamically.
11# For example, client.api_keys.get() results in a GET request to /v3/api_keys
12response = client.api_keys.get()
13
14print(response.status_code)
15print(response.body)
16print(response.headers)