Skip to content

Commit fba3cbb

Browse files
committed
Fix Python examples
1 parent 4bdd893 commit fba3cbb

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

content/geoip/geolocate-an-ip/web-services.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,25 @@ $client = new Client($account_id, $license_key, ['en'], ['host' => 'geolite.info
133133
```
134134

135135
```python
136+
import asyncio # for async requests with AsyncClient
137+
import geoip2.webservice
138+
139+
account_id = 10
140+
license_key = 'LICENSEKEY'
141+
136142
# If you want to use synchronous requests
137-
client = Client(10, 'LICENSEKEY');
143+
client = Client(account_id, license_key)
144+
138145
# To query the GeoLite web service, you must set the "host" keyword argument
139146
# to "geolite.info"
140-
client = Client(10, 'LICENSEKEY', host='geolite.info');
147+
client = Client(account_id, license_key, host='geolite.info')
141148

142149
# Or if you want to use asynchronous requests
143-
async_client = AsyncClient(10, 'LICENSEKEY');
150+
async_client = AsyncClient(account_id, license_key)
144151

145152
# To query the GeoLite web service, you must set the "host" keyword argument
146153
# to "geolite.info"
147-
async_client = AsyncClient(10, 'LICENSEKEY', host='geolite.info');
154+
async_client = AsyncClient(account_id, license_key, host='geolite.info')
148155
```
149156

150157
```ruby
@@ -250,7 +257,10 @@ print($record->country->isoCode . "\n");
250257
# Sync
251258
import geoip2.webservice
252259

253-
with geoip2.webservice.Client(10, 'license_key') as client:
260+
account_id = 10
261+
license_key = 'LICENSEKEY'
262+
263+
with geoip2.webservice.Client(account_id, license_key) as client:
254264
# You can also use `client.city` or `client.insights`
255265
# `client.insights` is not available to GeoLite users
256266
response = client.country('128.101.101.101)
@@ -262,7 +272,7 @@ import asyncio
262272
import geoip2.webservice
263273

264274
async def main():
265-
async with geoip2.webservice.AsyncClient(10, 'license_key') as client:
275+
async with geoip2.webservice.AsyncClient(account_id, license_key) as client:
266276
# You can also use `client.city` or `client.insights`
267277
# `client.insights` is not available to GeoLite users
268278
response = await client.country('128.101.101.101)

0 commit comments

Comments
 (0)