Skip to main content

Python helper to request Sirene Api on api.insee.fr

Project description

Python helper to request Sirene API

API Sirene give access to French companies and business database. Entities are recorded since the creation of this administrative register in 1973. To use this API you have to create an account on https://api.insee.fr/

You will find the official documentation here. All examples described here comes from the official documentation.

Installation

You can install the helper with pip

pip install api-insee

To use the api within a python script

from api_insee import ApiInsee

api = ApiInsee(
    key = # your consumer key,
    secret = # your consumer secret
)

Siren and Siret service

To get information about a siren number

data = api.siren('005520135').get()

This simple code call https://api.insee.fr/entreprises/sirene/V3/siren/005520135 and return these data :

{
  "header": {
    "statut": 200,
    "message": "OK"
  },
  "uniteLegale": {
    "siren": "005520135",
    ...
    "periodesUniteLegale": [
      {
        "dateFin": null,
        "dateDebut": "2007-11-19",
        "etatAdministratifUniteLegale": "C",
        "changementEtatAdministratifUniteLegale": true,
        "nomUniteLegale": null,
        ...
      }
      ...
    ]
  }
}

The same logic for a siret number

data = api.siret('39860733300059').get()
# call https://api.insee.fr/entreprises/sirene/V3/siret/39860733300059

Request Params

To pass url params to your request use keyword argument

data = api.siren('005520135', date='2018-01-01').get()
# https://api.insee.fr/entreprises/sirene/V3/siren/005520135?date=2018-01-01

Pagination

The pages() method return an iterator to let you fetch pages from the api. To specify the number of results per page use the nombre argument. Results are limited by 10000 per pages.

```python from api_insee import ApiInsee

api = ApiInsee( key = ‘YOUR-KEY’, secret = ‘YOUR-SECRET )

request = api.siren(q={ ‘categorieEntreprise’: ‘PME’ })

for (page_index, page_result) in enumerate(request.pages(nombre=1000)): # process page_result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

api_insee-1.2-py2.py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page