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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

Details for the file api_insee-1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: api_insee-1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8

File hashes

Hashes for api_insee-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dcdffff8a5b5e73237523a50cfa9bca09c9df6fc46d7bcf97ab67db41d0f63a7
MD5 a21b0188a6356906c4f12084c56a331a
BLAKE2b-256 662fb8dbbfbaf458792bbbe8d373ed2be08c065521edb4425b787fdefc588370

See more details on using hashes here.

Supported by

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