From ab625805aae81b3c06d73b5b309567360c902545 Mon Sep 17 00:00:00 2001 From: ipapi-co Date: Sun, 18 Dec 2016 19:43:02 +0530 Subject: [PATCH] Update README.md --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 059e6d8..00f2997 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,90 @@ -# ipapi-python -Python bindings for ipapi (IP address location API) + +# Python bindings for ipapi (IP address location API) + +## Installation + +``` +python setup.py install +``` + +## Usage + +### From your Python code + +``` +import ipapi + +``` + +``` +ipapi.location() +# Gets complete location for your IP address +# {u'city': u'Wilton', u'ip': u'50.1.2.3', u'region': u'California', u'longitude': -121.2429, u'country': u'US', u'latitude': 38.3926, u'timezone': u'America/Los_Angeles', u'postal': u'95693'} +``` + +``` +ipapi.field('ip') +# Gets my external IP address +# u'50.1.2.3' +``` + +``` +ipapi.field('city') +# Gets your city name +# u'Wilton' +``` + +``` +ipapi.field('country') +# Gets your country +# u'US' +``` + +``` +ipapi.location('8.8.8.8') +# Gets complete location for IP address 8.8.8.8 +# {u'city': u'Mountain View', u'ip': u'8.8.8.8', u'region': u'California', u'longitude': -122.0838, u'country': u'US', u'latitude': 37.386, u'timezone': u'America/Los_Angeles', u'postal': u'94035'} +``` + +``` +ipapi.field('city', '8.8.8.8') +# Gets city name for IP address 8.8.8.8 +# u'Mountain View' +``` + +``` +ipapi.field('country', '8.8.8.8') +# Gets country for IP address 8.8.8.8 +# u'US' +``` + +### From command line +``` +$ python ipapi.py +{u'city': u'Wilton', u'ip': u'50.1.2.3', u'region': u'California', u'longitude': -121.2429, u'country': u'US', u'latitude': 38.3926, u'timezone': u'America/Los_Angeles', u'postal': u'95693'} +``` + +``` +$ python ipapi.py -f ip +50.1.2.3 +``` + +``` +$ python ipapi.py -f city +Wilton +``` + +``` +$ python ipapi.py -i 8.8.8.8 +{u'city': u'Mountain View', u'ip': u'8.8.8.8', u'region': u'California', u'longitude': -122.0838, u'country': u'US', u'latitude': 37.386, u'timezone': u'America/Los_Angeles', u'postal': u'94035'} +``` + +``` +$ python ipapi.py -i 8.8.8.8 -f city +Mountain View +``` + +``` +$ python ipapi.py -i 8.8.8.8 -f country +US +```