@@ -42,17 +42,20 @@ IP geolocation is inherently imprecise. Locations are often near the center of
4242the population. Any location provided by a GeoIP2 database or web service
4343should not be used to identify a particular address or household.
4444
45- Usage
46- -----
45+ Web Service Usage
46+ -----------------
4747
48- To use this API, you first create either a web service object with your
49- MaxMind ``account_id `` and ``license_key `` or a database reader object with the
50- path to your database file. After doing this, you may call the method
51- corresponding to request type (e.g., ``city `` or ``country ``), passing it the
52- IP address you want to look up.
48+ To use this API, you first construct either a ``geoip2.webservice.Client `` or
49+ ``geoip2.webservice.AsyncClient ``, passing your MaxMind ``account_id `` and
50+ ``license_key `` to the constructor. To use the GeoLite2 web service instead of
51+ GeoIP2 Precision, set the optional ``host `` keyword argument to
52+ ``geolite.info ``.
53+
54+ After doing this, you may call the method corresponding to request type
55+ (e.g., ``city `` or ``country ``), passing it the IP address you want to look up.
5356
5457If the request succeeds, the method call will return a model class for the
55- end point you called. This model in turn contains multiple record classes,
58+ endpoint you called. This model in turn contains multiple record classes,
5659each of which represents part of the data returned by the web service.
5760
5861If the request fails, the client class throws an exception.
@@ -66,12 +69,14 @@ Sync Web Service Example
6669 >>>
6770 >>> # This creates a Client object that can be reused across requests.
6871 >>> # Replace "42" with your account ID and "license_key" with your license
69- >>> # key.
72+ >>> # key. Set the "host" keyword argument to "geolite.info" to use the
73+ >>> # GeoLite2 web service instead of GeoIP2 Precision.
7074 >>> with geoip2.webservice.Client(42, 'license_key') as client:
7175 >>>
72- >>> # Replace "insights" with the method corresponding to the web service
73- >>> # that you are using, e.g., "country", "city".
74- >>> response = client.insights('203.0.113.0')
76+ >>> # Replace "city" with the method corresponding to the web service
77+ >>> # that you are using, i.e., "country", "city", or "insights". Please
78+ >>> # note that Insights is not supported by the GeoLite2 web service.
79+ >>> response = client.city('203.0.113.0')
7580 >>>
7681 >>> response.country.iso_code
7782 'US'
@@ -114,12 +119,14 @@ Async Web Service Example
114119 >>> # loops, you must ensure the object is not used on another loop.
115120 >>> #
116121 >>> # Replace "42" with your account ID and "license_key" with your license
117- >>> # key.
122+ >>> # key. Set the "host" keyword argument to "geolite.info" to use the
123+ >>> # GeoLite2 web service instead of GeoIP2 Precision.
118124 >>> async with geoip2.webservice.AsyncClient(42, 'license_key') as client:
119125 >>>
120- >>> # Replace "insights" with the method corresponding to the web service
121- >>> # that you are using, e.g., "country", "city".
122- >>> response = await client.insights('203.0.113.0')
126+ >>> # Replace "city" with the method corresponding to the web service
127+ >>> # that you are using, i.e., "country", "city", or "insights". Please
128+ >>> # note that Insights is not supported by the GeoLite2 web service.
129+ >>> response = await client.city('203.0.113.0')
123130 >>>
124131 >>> response.country.iso_code
125132 'US'
@@ -169,8 +176,22 @@ returns any status code besides 200, 4xx, or 5xx, this also becomes an
169176Finally, if the web service returns a 200 but the body is invalid, the client
170177throws a ``GeoIP2Error ``.
171178
179+ Database Usage
180+ --------------
181+
182+ To use the database API, you first construct a ``geoip2.database.Reader `` using
183+ the path to the file as the first argument. After doing this, you may call the
184+ method corresponding to database type (e.g., ``city `` or ``country ``), passing it
185+ the IP address you want to look up.
186+
187+ If the lookup succeeds, the method call will return a model class for the
188+ database method you called. This model in turn contains multiple record classes,
189+ each of which represents part of the data for the record.
190+
191+ If the request fails, the reader class throws an exception.
192+
172193Database Example
173- -------------------
194+ ----------------
174195
175196City Database
176197^^^^^^^^^^^^^
@@ -399,7 +420,7 @@ What data is returned?
399420----------------------
400421
401422While many of the models contain the same basic records, the attributes which
402- can be populated vary between web service end points or databases. In
423+ can be populated vary between web service endpoints or databases. In
403424addition, while a model may offer a particular piece of data, MaxMind does not
404425always have every piece of data for any given IP address.
405426
0 commit comments