Utils

pynsee.utils.init_conn(insee_key, insee_secret, http_proxy='', https_proxy='')

Save your credentials to connect to INSEE APIs, subscribe to api.insee.fr

Args:

insee_key (str): user’s key insee_secret (str): user’s secret http_proxy (str, optional): Proxy server address, e.g. ‘http://my_proxy_server:port’. Defaults to “”. https_proxy (str, optional): Proxy server address, e.g. ‘http://my_proxy_server:port’. Defaults to “”.

Notes:

Environment variables can be used instead of init_conn function

Examples:
>>> from pynsee.utils.init_conn import init_conn
>>> init_conn(insee_key="my_insee_key", insee_secret="my_insee_secret")
>>> #
>>> # if the user has to use a proxy server use http_proxy and https_proxy arguments as follows:
>>> from pynsee.utils.init_conn import init_conn
>>> init_conn(insee_key="my_insee_key",
>>>           insee_secret="my_insee_secret",
>>>           http_proxy="http://my_proxy_server:port",
>>>           https_proxy="http://my_proxy_server:port")
>>> #
>>> # Alternativety you can use directly environment variables as follows:
>>> # Beware not to commit your credentials!
>>> import os
>>> os.environ['insee_key'] = 'my_insee_key'
>>> os.environ['insee_secret'] = 'my_insee_secret'
>>> os.environ['http_proxy'] = "http://my_proxy_server:port"
>>> os.environ['https_proxy'] = "http://my_proxy_server:port"
pynsee.utils.clear_all_cache()

Clear the cache of all functions

Notes:

If the credentials provided fail to get a token from api.insee.fr even after a double check, try to clear the cache as the output of the function retrieving the token is cached even it is an error.

Examples:
>>> from pynsee.utils import clear_all_cache
>>> clear_all_cache()