-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |