Skip to content

Commit dc0f2c1

Browse files
committed
Updated README.md
1 parent 81670c3 commit dc0f2c1

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

README.md

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,75 @@ You can add custom headers or modify default headers by setting the `headers` ke
240240

241241
### Internationalization
242242

243-
When looking up an IP address, the response object includes `details.country_name`, `details.isEU`, `details.country_flag`, `details.country_flag_url` and `details.country_currency` attributes which includes the country based on American English. It is possible to return the country name in other languages by setting the `countries_file`, remove or add EU countries by setting the keyword argument `eu_countries_file`, change the country flag emoji or unicode by setting the keyword argument `countries_flags_file` or change country's currency code or currency symbol by setting the `countries_currencies` when creating the `IPinfo` object. Moreover, the response object includes a `details.continent` which includes continent code and name of IP. The default file can be changed by setting the `continent_file` while creating the `IPinfo` object.
243+
When looking up an IP address, the response object includes `details.country_name`, `details.isEU`, `details.country_flag`, `details.country_flag_url` and `details.country_currency` attributes which includes the country based on American English. It is possible to return the country name in other languages by setting the `countries`, remove or add EU countries by setting the keyword argument `eu_countries`, change the country flag emoji or unicode by setting the keyword argument `countries_flags` or change country's currency code or currency symbol by setting the `countries_currencies` when creating the `IPinfo` object. Moreover, the response object includes a `details.continent` which includes continent code and name of IP. The default file can be changed by setting the `continent` while creating the `IPinfo` object.
244244

245-
The file must be a `.json` file with the following structure:
245+
```python
246+
>>> import ipinfo
247+
```
246248

247-
```json
248-
{
249-
"BD": {"name":"Bangladesh", "isEU":false},
250-
"BE": {"name":"Belgium", "isEU":true},
251-
"BF": {"name":"Burkina Faso", "isEU":false},
252-
"BG": {"name":"Bulgaria", "isEU":true},
253-
...
249+
#### Country Names (`countries`):
250+
Set the countries keyword argument or provide an in-memory map to customize country names.
251+
```python
252+
>>> countries = {
253+
"BD": "Bangladesh",
254+
"BE": "Belgium",
255+
"BF": "Burkina Faso",
256+
...
254257
}
255258
```
259+
#### EU Countries (`eu_countries`):
260+
Set the eu_countries keyword argument or provide an in-memory list to customize EU countries.
256261

262+
```python
263+
>>> eu_countries = [
264+
"IE",
265+
"AT",
266+
"LT",
267+
...
268+
]
269+
```
270+
#### Country Flags (`countries_flags`):
271+
Set the countries_flags keyword argument or provide an in-memory map to customize country flags.
272+
```python
273+
>>> countries_flags = {
274+
"AD": {"emoji": "🇦🇩", "unicode": "U+1F1E6 U+1F1E9"},
275+
"AE": {"emoji": "🇦🇪", "unicode": "U+1F1E6 U+1F1EA"},
276+
"AF": {"emoji": "🇦🇫", "unicode": "U+1F1E6 U+1F1EB"},
277+
...
278+
}
279+
```
280+
#### Country Currencies (`countries_currencies`):
281+
Set the countries_currencies keyword argument or provide an in-memory map to customize country currencies.
282+
```python
283+
>>> countries_currencies = {
284+
"AD": {"code": "EUR", "symbol": ""},
285+
"AE": {"code": "AED", "symbol": "د.إ"},
286+
"AF": {"code": "AFN", "symbol": "؋"},
287+
...
288+
}
289+
```
290+
#### Continents (`continents`):
291+
Set the continents keyword argument or provide an in-memory map to customize continent details.
292+
```python
293+
>>> continents = {
294+
"BD": {"code": "AS", "name": "Asia"},
295+
"BE": {"code": "EU", "name": "Europe"},
296+
"BF": {"code": "AF", "name": "Africa"},
297+
...
298+
}
299+
```
300+
#### Usage:
301+
```python
302+
>>> access_token = '123456789abc'
303+
>>> handler = ipinfo.getHandler(
304+
access_token,
305+
countries=countries,
306+
eu_countries=eu_countries,
307+
countries_flags=countries_flags,
308+
countries_currencies=countries_currencies,
309+
continents=continents
310+
)
311+
```
257312
### Batch Operations
258313

259314
Looking up a single IP at a time can be slow. It could be done concurrently

0 commit comments

Comments
 (0)