Created
November 20, 2014 19:55
-
-
Save kpx-dev/fb740ba73d4c009732c5 to your computer and use it in GitHub Desktop.
SendGrid block example with requests library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This Python code snippet will show you how to get all SendGrid block records | |
Please change SG_USERNAME and SG_PASSWORD to match your credentials | |
install the amazing requests library | |
$ pip install requests==2.4.3 | |
save this file as python block.py and run it | |
$ python block.py | |
""" | |
import requests | |
SG_USERNAME = '' | |
SG_PASSWORD = '' | |
SG_URL = "https://sendgrid.com/api" | |
if __name__ == '__main__': | |
block_url = "{}/blocks.get.json?api_user={}&api_key={}".format( | |
SG_URL, SG_USERNAME, SG_PASSWORD) | |
res = requests.get(block_url) | |
# Example output: | |
# [{u'status': u'4.0.0', u'reason': u'Unable to resolve MX host example.com: noerror', u'email': u'[email protected]'}] | |
print res.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment