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
`ipinfo_wrapper` is a lightweight wrapper for the IPinfo API, which provides up-to-date IP address data.
4
+
``ipinfo_wrapper`` is a lightweight wrapper for the IPinfo API, which provides up-to-date IP address data.
5
5
6
6
.. contents::
7
7
@@ -10,7 +10,7 @@ The official Python library for the `IPinfo <https://ipinfo.io/>`_ API.
10
10
Usage
11
11
=====
12
12
13
-
The `Handler.getDetails()` method accepts an IP address as an optional, positional argument. If no IP address is specified, the API will return data for the IP address from which it receives the request.
13
+
The ``Handler.getDetails()`` method accepts an IP address as an optional, positional argument. If no IP address is specified, the API will return data for the IP address from which it receives the request.
14
14
15
15
>>> import ipinfo_wrapper
16
16
>>> access_token ='123456789abc'
@@ -32,7 +32,7 @@ The IPinfo library can be authenticated with your IPinfo API token, which is pas
32
32
33
33
Details Data
34
34
=============
35
-
`handler.getDetails()` will return a `Details` object that contains all fields listed `IPinfo developer docs <https://ipinfo.io/developers/responses#full-response>`_ with a few minor additions. Properties can be accessed directly.
35
+
``handler.getDetails()`` will return a ``Details`` object that contains all fields listed `IPinfo developer docs <https://ipinfo.io/developers/responses#full-response>`_ with a few minor additions. Properties can be accessed directly.
`details.country_name` will return the country name, as supplied by the `countries.json` file. See below for instructions on changing that file for use with non-English languages. `details.country` will still return country code.
44
+
``details.country_name`` will return the country name, as supplied by the ``countries.json`` file. See below for instructions on changing that file for use with non-English languages. ``details.country`` will still return country code.
45
45
46
46
>>> details.country
47
47
US
@@ -51,7 +51,7 @@ United States
51
51
IP Address
52
52
----------
53
53
54
-
`details.ip_address` will return the an `ipaddress` object from the `Python Standard Library <https://docs.python.org/3/library/ipaddress.html>`_. `details.ip` will still return a string.
54
+
``details.ip_address`` will return the an ``ipaddress`` object from the `Python Standard Library <https://docs.python.org/3/library/ipaddress.html>`_. ``details.ip`` will still return a string.
55
55
56
56
>>> details.ip
57
57
104.175.221.247
@@ -65,7 +65,7 @@ IP Address
65
65
Longitude and Latitude
66
66
----------------------
67
67
68
-
`details.latitude` and `details.longitude` will return latitude and longitude, respectively, as strings. `details.loc` will still return a composite string of both values.
68
+
``details.latitude`` and ``details.longitude`` will return latitude and longitude, respectively, as strings. ``details.loc`` will still return a composite string of both values.
69
69
70
70
>>> details.loc
71
71
34.0293,-118.3570
@@ -77,7 +77,7 @@ Longitude and Latitude
77
77
Accessing all properties
78
78
------------------------
79
79
80
-
`details.all` will return all details data as a dictionary.
80
+
``details.all`` will return all details data as a dictionary.
81
81
82
82
>>> details.all
83
83
{
@@ -105,12 +105,12 @@ Accessing all properties
105
105
106
106
Caching
107
107
=======
108
-
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.
108
+
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.
109
109
110
110
Modifying cache options
111
111
-----------------------
112
112
113
-
Cache behavior can be modified by setting the `cache_options` keyword argument. `cache_options` is a dictionary in which the keys are keyword arguments specified in the `cachetools` library. The nesting of keyword arguments is to prevent name collisions between this library and its dependencies.
113
+
Cache behavior can be modified by setting the ``cache_options`` keyword argument. ``cache_options`` is a dictionary in which the keys are keyword arguments specified in the ``cachetools`` library. The nesting of keyword arguments is to prevent name collisions between this library and its dependencies.
114
114
115
115
* Default maximum cache size: 4096 (multiples of 2 are recommended to increase efficiency)
116
116
* Default TTL: 24 hours (in seconds)
@@ -120,16 +120,16 @@ Cache behavior can be modified by setting the `cache_options` keyword argument.
120
120
Using a different cache
121
121
-----------------------
122
122
123
-
It's possible to use a custom cache by creating a child class of the `CacheInterface <https://github.com/jhtimmins/ipinfo-python/blob/master/cache/interface.py>`_ class and passing this into the handler object with the `cache` keyword argument. FYI this is known as `the Strategy Pattern <https://sourcemaking.com/design_patterns/strategy>`_.
123
+
It's possible to use a custom cache by creating a child class of the `CacheInterface <https://github.com/jhtimmins/ipinfo-python/blob/master/cache/interface.py>`_ class and passing this into the handler object with the ``cache`` keyword argument. FYI this is known as `the Strategy Pattern <https://sourcemaking.com/design_patterns/strategy>`_.
When looking up an IP address, the response object includes a `details.country_name` attribute which includes the country name based on American English. It is possible to return the country name in other languages by setting the `countries_file` keyword argument when creating the `IPinfo` object.
130
+
When looking up an IP address, the response object includes a ``details.country_name`` attribute which includes the country name based on American English. It is possible to return the country name in other languages by setting the ``countries_file`` keyword argument when creating the ``IPinfo`` object.
131
131
132
-
The file must be a `.json` file with the following structure::
132
+
The file must be a ``.json`` file with the following structure::
0 commit comments