Skip to content

Commit cb8489a

Browse files
authored
usage syntax added
1 parent 27f1cbf commit cb8489a

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

README.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ python setup.py install
1818

1919
```
2020
import ipapi
21+
ipapi.location(ip=None, key=None, field=None)
22+
```
23+
24+
- `ip` : use specified IP address. If omitted or `None`, use your machine's IP address
25+
- `key` : For paid plans
26+
- `field` : get specified field (ip, city, country, timezone etc.) as text. If omitted or `None`, get entire location data as `JSON`
2127

28+
#### Examples
29+
30+
```
2231
ipapi.location()
2332
# Gets complete location for your IP address
2433
{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'}
@@ -50,6 +59,12 @@ u'US'
5059

5160

5261
### From command line
62+
```
63+
$ python ipapi.py -i <IP address> -f <field> -k <API KEY>
64+
```
65+
66+
#### Examples
67+
5368
```
5469
$ python ipapi.py
5570
{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'}
@@ -79,32 +94,6 @@ API key can be specified in the following ways :
7994
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')`
8095

8196
### 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')`
85-
86-
87-
### Error
88-
- If you are getting `requests.exceptions.SSLError` (see below), then you need to run :
89-
90-
`pip install requests[security]`
91-
92-
```
93-
94-
Traceback (most recent call last):
95-
File "<stdin>", line 1, in <module>
96-
File "ipapi.py", line 45, in field
97-
response = get(url, headers=headers)
98-
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
99-
return request('get', url, **kwargs)
100-
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
101-
return session.request(method=method, url=url, **kwargs)
102-
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
103-
resp = self.send(prep, **send_kwargs)
104-
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send
105-
r = adapter.send(request, **kwargs)
106-
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 385, in send
107-
raise SSLError(e)
108-
requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
109-
```
110-
97+
- All function arguments (`ip`, `key`, `field`) are optional . To skip an argument, use `None` or an empty string `''`.
98+
`ipapi.location(ip='8.8.8.8', key=None, field='city')`
99+
`ipapi.location(ip='8.8.8.8', key='', field='city')`

0 commit comments

Comments
 (0)