Skip to content

Commit edb6787

Browse files
authored
Combine field & location functions
1 parent 5b91b70 commit edb6787

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pip install ipapi
88
```
99
or
10+
1011
```
1112
python setup.py install
1213
```
@@ -22,27 +23,27 @@ ipapi.location()
2223
# Gets complete location for your IP address
2324
{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'}
2425
25-
ipapi.field('ip')
26+
ipapi.location(None, None, 'ip')
2627
# Gets my external IP address
2728
u'50.1.2.3'
2829
29-
ipapi.field('city')
30+
ipapi.location(None, None, 'city')
3031
# Gets your city name
3132
u'Wilton'
3233
33-
ipapi.field('country')
34+
ipapi.location(None, None, 'country')
3435
# Gets your country
3536
u'US'
3637
3738
ipapi.location('8.8.8.8')
3839
# Gets complete location for IP address 8.8.8.8
3940
{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'}
4041
41-
ipapi.field('city', '8.8.8.8')
42+
ipapi.location('8.8.8.8', None, 'city')
4243
# Gets city name for IP address 8.8.8.8
4344
u'Mountain View'
4445
45-
ipapi.field('country', '8.8.8.8')
46+
ipapi.location('8.8.8.8', None, 'country')
4647
# Gets country for IP address 8.8.8.8
4748
u'US'
4849
```
@@ -75,4 +76,9 @@ API key can be specified in the following ways :
7576

7677
1. Inside `ipapi.py` by setting `API_KEY` variable
7778
2. Via command line with the `-k` option
78-
3. As a function argument e.g. `ipapi.field(field='country', ip='8.8.8.8', key='xyz')` or `ipapi.location(ip='8.8.8.8', key='xyz')`
79+
3. As a function argument e.g. `ipapi.location(ip='8.8.8.8', key='secret-key')` or `ipapi.location(ip='8.8.8.8', key='secret-key', field='city')`
80+
81+
### Notes
82+
- All function arguments (`ip`, `key`, `field`) are optional . To skip an argument, use `None` or an empty string `''`.
83+
`ipapi.location(ip='8.8.8.8', key=None, field='city')`
84+
`ipapi.location(ip='8.8.8.8', key='', field='city')`

0 commit comments

Comments
 (0)