You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ You'll need an IPinfo API access token, which you can get by signing up for a fr
15
15
16
16
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)
17
17
18
-
⚠️ Note: This library does not currently support our newest free APIhttps://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.
18
+
The library also supports the Lite API, see the [Lite API section](#lite-api) for more info.
19
19
20
20
#### Installation
21
21
@@ -48,6 +48,7 @@ will return the following as an `HttpResponse` object:
48
48
```
49
49
50
50
To get the details of a user-defined IP, we will import the ipinfo package directly to the `view.py` file:
51
+
51
52
```python
52
53
from django.shortcuts import render
53
54
from django.http import HttpResponse
@@ -207,7 +208,7 @@ IPINFO_TOKEN = '123456789abc'
207
208
208
209
### Caching
209
210
210
-
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.
211
+
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.
211
212
212
213
#### Modifying cache options
213
214
@@ -269,10 +270,10 @@ To turn off filtering:
269
270
IPINFO_FILTER=None
270
271
```
271
272
272
-
To set your own filtering rules, *thereby replacing the default filter*, you can set `settings.IPINFO_FILTER` to your own, custom callable function which satisfies the following rules:
273
+
To set your own filtering rules, _thereby replacing the default filter_, you can set `settings.IPINFO_FILTER` to your own, custom callable function which satisfies the following rules:
273
274
274
275
- Accepts one request.
275
-
- Returns *True to filter out, False to allow lookup*
276
+
- Returns _True to filter out, False to allow lookup_
276
277
277
278
To use your own filter rules:
278
279
@@ -331,6 +332,25 @@ If there's an error while making a request to IPinfo (e.g. your token was rate
331
332
limited, there was a network issue, etc.), then the traceback will be logged
332
333
using the built-in Python logger, and `HttpRequest.ipinfo` will be `None`.
333
334
335
+
### Lite API
336
+
337
+
The library gives the possibility to use the [Lite API](https://ipinfo.io/developers/lite-api) too, authentication with your token is still required.
338
+
339
+
The IP details returned are slightly different from the Core API middleware, though the arguments are identical.
340
+
341
+
To use it add `'ipinfo_django.middleware.IPinfoLiteMiddleware'` to `settings.MIDDLEWARE` in `settings.py`:
0 commit comments