From 436f3119f9ac28c559f96414ba3b3f85cbddb2ef Mon Sep 17 00:00:00 2001 From: Michael Herman Date: Sun, 25 Oct 2015 15:20:53 -0600 Subject: [PATCH] Added fullcontact api --- 30_fullcontact.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 1 + 2 files changed, 50 insertions(+) create mode 100644 30_fullcontact.py diff --git a/30_fullcontact.py b/30_fullcontact.py new file mode 100644 index 0000000..a612648 --- /dev/null +++ b/30_fullcontact.py @@ -0,0 +1,49 @@ +import sys +import requests + +""" + +1. pip install requests +2. Obtain an API key: https://www.fullcontact.com/developer/pricing/ + +Example usage: + +$ python 30_fullcontact.py email SOME@EMAIL.COM +$ python 30_fullcontact.py twitter TWITTER_HANDLE +""" + + +# constants + +API_KEY = 'GET YOUR OWN' +BASE_URL = 'http://api.fullcontact.com/v2/person.json' + + +# helpers + +def get_arguments(): + if len(sys.argv) is 3: + return { + 'media': sys.argv[1], + 'user_info': sys.argv[2] + } + else: + print('Specify at least 1 argument') + sys.exit() + + +def call_api(contact): + url = BASE_URL + '?{0}={1}&apiKey={2}'.format( + contact['media'], contact['user_info'], API_KEY) + r = requests.get(url) + if r.status_code == 200: + return r.text + else: + return "Sorry, no results found." + + +# main + +if __name__ == "__main__": + media = get_arguments() + print(call_api(media)) diff --git a/readme.md b/readme.md index cf967f4..0bfba2f 100644 --- a/readme.md +++ b/readme.md @@ -29,3 +29,4 @@ 1. **27_send_sms.py**: Send SMS message via [TextBelt](http://textbelt.com/) 1. **28_income_tax_calculator.py**: Income tax calculator via [Taxee](http://taxee.io/) 1. **29_json_to_yaml.py**: Convert JSON to YAML +1. **30_fullcontact.py**: Call the [FullcContact](https://www.fullcontact.com/developer/) API