irenee

wild APIs at http://www.insee.fr


Keywords
insee, API
License
Other
Install
pip install irenee==2.0

Documentation

irenee : wild APIs from insee website

turns http://www.insee.fr online services into nice and handy APIs !

irenee depends on the following modules:

  • requests
  • bs4 (BeautifulSoup)
  • docopt
  • pandas

Consider using Grohlke repos for easy install windows binaries (http://www.lfd.uci.edu/~gohlke/pythonlibs/)

install

$ pip install irenee

irenee.catfish: get category from siren ID

catfish submodule uses http://www.insee.fr/fr/service/entreprises/categorie-form.asp to retrieve information on companies identified by siren ID (for definitions: http://www.insee.fr/fr/methodes/)

usage

$ from irenee import catfish

get data for a single siren ID

$ catfish.get('666999666')

compute a list of sirens

$ sirens = [
    '666666666',
    '999999999',
    '696969696',
    ....]
$ res = [catfish.get(siren) for sire in sirens]

compute a xlsx file containing sirens (colA)

$ catfish.batch('in.xlsx', 'out.xlsx)

irenee.cog: get cog changelogs

COG = "Code Officiel Geographique"

cog submodule uses http://www.insee.fr/fr/methodes/nomenclatures/cog/recherche_historique.asp to retrieve COG changelog cog has one method: get(start, end, deplist=['00'], modlist=['M0'], xlsx=None) which returns a pandas.DataFrame. cog also can export to xlsx.

usage

import

$ from irenee import cog

time interval

get changelogs for all municipalities between 2000 and 2015

$ log = cog.get('2000', '2015')

departements

Departements are queried as a list of dep codes : get changelogs between 2000 and 2015 for a list of departements:

$ deps = [
    '01',
    '07',
    '26',
    ...]
$ log = cog.get('2000', '2015', deplist=deps)

modifications types

List of modtypes:

  • MA: Changement de nom
  • MB: Création / rétablissement
  • MC: Modification cantonale
  • MD: Changement de dep. / d'arrond.
  • ME: Suppression / fusion
  • MF: Transfert de chef-lieu
  • MG: Echange de parcelles

Modifications are queried as a list of modtypes : get changelogs between 2000 and 2015 for a list of modtypes:

$ mods = [
    'MA',
    'MB',
    'MC',
    ...]
$ cog.get('2000', '2015', modlist=mods)

export to xlsx

cog will export to xlsx if path is provided:

$ cog.get('2000', '2015', xlsx='/path/to/file.xlsx')