Skip to content

Commit 7aefc4b

Browse files
authored
Merge pull request #119 from ipinfo/silvano/eng-603-update-readme-documentation-for-ipinfopython
Add documentation for Core and Plus bundles and resproxy
2 parents 35a0405 + 036d13f commit 7aefc4b

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,79 @@ The returned details are slightly different from the Core API.
180180
'United States'
181181
```
182182

183+
### Core API
184+
185+
The library also supports the [Core API](https://ipinfo.io/developers/data-types#core-data), which provides city-level geolocation with nested geo and AS objects. Authentication with your token is required.
186+
187+
```python
188+
>>> import ipinfo
189+
>>> handler = ipinfo.getHandlerCore(access_token='123456789abc')
190+
>>> details = handler.getDetails("8.8.8.8")
191+
>>> details.ip
192+
'8.8.8.8'
193+
>>> details.geo
194+
{'city': 'Mountain View', 'region': 'California', 'region_code': 'CA', 'country': 'United States', 'country_code': 'US', ...}
195+
>>> details.all['as']
196+
{'asn': 'AS15169', 'name': 'Google LLC', 'domain': 'google.com', 'type': 'hosting', ...}
197+
```
198+
199+
An asynchronous handler is also available:
200+
201+
```python
202+
>>> handler = ipinfo.getHandlerAsyncCore(access_token='123456789abc')
203+
>>> details = await handler.getDetails("8.8.8.8")
204+
```
205+
206+
### Plus API
207+
208+
The library also supports the [Plus API](https://ipinfo.io/developers/data-types#plus-data), which provides enhanced data including mobile carrier info and privacy detection. Authentication with your token is required.
209+
210+
```python
211+
>>> import ipinfo
212+
>>> handler = ipinfo.getHandlerPlus(access_token='123456789abc')
213+
>>> details = handler.getDetails("8.8.8.8")
214+
>>> details.ip
215+
'8.8.8.8'
216+
>>> details.geo
217+
{'city': 'Mountain View', 'region': 'California', 'region_code': 'CA', 'country': 'United States', 'country_code': 'US', ...}
218+
>>> details.mobile
219+
{'carrier': ..., 'mcc': ..., 'mnc': ...}
220+
>>> details.anonymous
221+
{'is_proxy': False, 'is_relay': False, 'is_tor': False, ...}
222+
```
223+
224+
An asynchronous handler is also available:
225+
226+
```python
227+
>>> handler = ipinfo.getHandlerAsyncPlus(access_token='123456789abc')
228+
>>> details = await handler.getDetails("8.8.8.8")
229+
```
230+
231+
### Residential Proxy API
232+
233+
The library also supports the [Residential Proxy API](https://ipinfo.io/developers/residential-proxy-api), which allows you to check if an IP address is a residential proxy. Authentication with your token is required.
234+
235+
```python
236+
>>> import ipinfo
237+
>>> handler = ipinfo.getHandler(access_token='123456789abc')
238+
>>> details = handler.getResproxy("175.107.211.204")
239+
>>> details.ip
240+
'175.107.211.204'
241+
>>> details.last_seen
242+
'2025-01-20'
243+
>>> details.percent_days_seen
244+
0.85
245+
>>> details.service
246+
'Bright Data'
247+
```
248+
249+
An asynchronous handler is also available:
250+
251+
```python
252+
>>> handler = ipinfo.getHandlerAsync(access_token='123456789abc')
253+
>>> details = await handler.getResproxy("175.107.211.204")
254+
```
255+
183256
### Caching
184257

185258
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.

0 commit comments

Comments
 (0)