nokey.geolocation package

Submodules

nokey.geolocation.ip_api module

class nokey.geolocation.ip_api.IP_API(use_caching=False, cache_name='ip_api_cache', backend='sqlite', expire_after=3600)[source]

Bases: object

A class to interact with the IP API.

base_url

The base URL of IP API.

about

A short description of the API.

get_docs_url()[source]

Returns URL for API docs.

Parameters:

None

Returns:

URL for API documentation.

Return type:

string

get_location_info_by_ip_address(ip)[source]

Returns geolocation info (country, state, coordinates, etc.) by IP address.

Parameters:

ip (str) – IPv4/IPv6 address or domain name.

Returns:

Location information based on given IP address or domain name.

Return type:

dict

nokey.geolocation.zippopotamus module

class nokey.geolocation.zippopotamus.Zippopotomus(use_caching=False, cache_name='zippopotomus_cache', backend='sqlite', expire_after=3600)[source]

Bases: object

A class to interact with the Zippopotomus API.

base_url

The basee URL of the API.

about

A short description of the API.

get_docs_url()[source]

Returns the URL for the Zippopotomus API documentation.

Parameters:

None

Returns:

The URL for the API docs.

Return type:

string

get_info_by_zipcode(country, zipcode)[source]

Returns information on a given zipcode in a given country.

Parameters:
  • country (str) – The country code as defined in the API docs. See docs for supported countries.

  • zipcode (int) – The zipcode in question. See docs for range and format of zipcodes by country.

Returns:

A dictionary containing information about the given zipcode in the given country.

Return type:

dict

get_zipcode_by_city(country, state, city)[source]

Returns the zipcode(s) of the city matching the parameters.

Parameters:
  • country (str) – The country code as defined in the API docs.

  • state (str) – The state code.

  • city (str) – The city in question.

Returns:

A dictionary containing the zipcode of the given location.

Return type:

dict

Module contents