|
2 | 2 |
|
3 | 3 | This is the official Python client library for the IPinfo.io IP address API, allowing you to look up your own IP address, or get any of the following details for an IP: |
4 | 4 |
|
5 | | - - [IP geolocation](https://ipinfo.io/ip-geolocation-api) (city, region, country, postal code, latitude, and longitude) |
6 | | - - [ASN details](https://ipinfo.io/asn-api) (ISP or network operator, associated domain name, and type, such as business, hosting, or company) |
7 | | - - [Firmographics data](https://ipinfo.io/ip-company-api) (the name and domain of the business that uses the IP address) |
8 | | - - [Carrier information](https://ipinfo.io/ip-carrier-api) (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic) |
| 5 | +- [IP geolocation](https://ipinfo.io/ip-geolocation-api) (city, region, country, postal code, latitude, and longitude) |
| 6 | +- [ASN details](https://ipinfo.io/asn-api) (ISP or network operator, associated domain name, and type, such as business, hosting, or company) |
| 7 | +- [Firmographics data](https://ipinfo.io/ip-company-api) (the name and domain of the business that uses the IP address) |
| 8 | +- [Carrier information](https://ipinfo.io/ip-carrier-api) (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic) |
9 | 9 |
|
10 | 10 | ## Getting Started |
11 | 11 |
|
12 | 12 | You'll need an IPinfo API access token, which you can get by signing up for a free account at [https://ipinfo.io/signup](https://ipinfo.io/signup). |
13 | 13 |
|
14 | 14 | The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see [https://ipinfo.io/pricing](https://ipinfo.io/pricing) |
15 | 15 |
|
16 | | -⚠️ Note: This library does not currently support our newest free API https://ipinfo.io/lite. If you’d like to use IPinfo Lite, you can call the [endpoint directly](https://ipinfo.io/developers/lite-api) using your preferred HTTP client. Developers are also welcome to contribute support for Lite by submitting a pull request. |
| 16 | +The library also supports the Lite API, see the [Lite API section](#lite-api) for more info. |
17 | 17 |
|
18 | 18 | ### Installation |
19 | 19 |
|
@@ -162,6 +162,22 @@ The IPinfo library can be authenticated with your IPinfo API token, which is pas |
162 | 162 | 'timezone': 'America/Los_Angeles'} |
163 | 163 | ``` |
164 | 164 |
|
| 165 | +### Lite API |
| 166 | + |
| 167 | +The library gives the possibility to use the [Lite API](https://ipinfo.io/developers/lite-api) too, authentication with your token is still required. |
| 168 | + |
| 169 | +The returned details are slightly different from the Core API. |
| 170 | + |
| 171 | +```python |
| 172 | +>>> import ipinfo |
| 173 | +>>> handler = ipinfo.getHandlerLite(access_token='123456789abc') |
| 174 | +>>> details = handler.getDetails("8.8.8.8") |
| 175 | +>>> details.country_code |
| 176 | +'US' |
| 177 | +>>> details.country |
| 178 | +'United States' |
| 179 | +``` |
| 180 | + |
165 | 181 | ### Caching |
166 | 182 |
|
167 | 183 | In-memory caching of `details` data is provided by default via the [cachetools](https://cachetools.readthedocs.io/en/latest/) library. This uses an LRU (least recently used) cache with a TTL (time to live) by default. This means that values will be cached for the specified duration; if the cache's max size is reached, cache values will be invalidated as necessary, starting with the oldest cached value. |
@@ -297,6 +313,7 @@ When looking up an IP address, the response object includes `details.country_nam |
297 | 313 | continents=continents |
298 | 314 | ) |
299 | 315 | ``` |
| 316 | + |
300 | 317 | ### Batch Operations |
301 | 318 |
|
302 | 319 | Looking up a single IP at a time can be slow. It could be done concurrently |
|
0 commit comments