|
1 |
| -# ipapi-python |
2 |
| -Python bindings for ipapi (IP address location API) |
| 1 | + |
| 2 | +# Python bindings for ipapi (IP address location API) |
| 3 | + |
| 4 | +## Installation |
| 5 | + |
| 6 | +``` |
| 7 | +python setup.py install |
| 8 | +``` |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +### From your Python code |
| 13 | + |
| 14 | +``` |
| 15 | +import ipapi |
| 16 | +
|
| 17 | +``` |
| 18 | + |
| 19 | +``` |
| 20 | +ipapi.location() |
| 21 | +# Gets complete location for your IP address |
| 22 | +# {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'} |
| 23 | +``` |
| 24 | + |
| 25 | +``` |
| 26 | +ipapi.field('ip') |
| 27 | +# Gets my external IP address |
| 28 | +# u'50.1.2.3' |
| 29 | +``` |
| 30 | + |
| 31 | +``` |
| 32 | +ipapi.field('city') |
| 33 | +# Gets your city name |
| 34 | +# u'Wilton' |
| 35 | +``` |
| 36 | + |
| 37 | +``` |
| 38 | +ipapi.field('country') |
| 39 | +# Gets your country |
| 40 | +# u'US' |
| 41 | +``` |
| 42 | + |
| 43 | +``` |
| 44 | +ipapi.location('8.8.8.8') |
| 45 | +# Gets complete location for IP address 8.8.8.8 |
| 46 | +# {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'} |
| 47 | +``` |
| 48 | + |
| 49 | +``` |
| 50 | +ipapi.field('city', '8.8.8.8') |
| 51 | +# Gets city name for IP address 8.8.8.8 |
| 52 | +# u'Mountain View' |
| 53 | +``` |
| 54 | + |
| 55 | +``` |
| 56 | +ipapi.field('country', '8.8.8.8') |
| 57 | +# Gets country for IP address 8.8.8.8 |
| 58 | +# u'US' |
| 59 | +``` |
| 60 | + |
| 61 | +### From command line |
| 62 | +``` |
| 63 | +$ python ipapi.py |
| 64 | +{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'} |
| 65 | +``` |
| 66 | + |
| 67 | +``` |
| 68 | +$ python ipapi.py -f ip |
| 69 | +50.1.2.3 |
| 70 | +``` |
| 71 | + |
| 72 | +``` |
| 73 | +$ python ipapi.py -f city |
| 74 | +Wilton |
| 75 | +``` |
| 76 | + |
| 77 | +``` |
| 78 | +$ python ipapi.py -i 8.8.8.8 |
| 79 | +{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'} |
| 80 | +``` |
| 81 | + |
| 82 | +``` |
| 83 | +$ python ipapi.py -i 8.8.8.8 -f city |
| 84 | +Mountain View |
| 85 | +``` |
| 86 | + |
| 87 | +``` |
| 88 | +$ python ipapi.py -i 8.8.8.8 -f country |
| 89 | +US |
| 90 | +``` |
0 commit comments