Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapi-co authored Dec 18, 2016
1 parent e95ea69 commit ab62580
Showing 1 changed file with 90 additions and 2 deletions.
92 changes: 90 additions & 2 deletions README.md
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
```

0 comments on commit ab62580

Please sign in to comment.