{"id":21997594,"url":"https://github.com/stephane-klein/data-gouv-sirene-postgres-postgrest","last_synced_at":"2026-04-16T08:34:26.690Z","repository":{"id":99039615,"uuid":"262529779","full_name":"stephane-klein/data-gouv-sirene-postgres-postgrest","owner":"stephane-klein","description":"Import data.gouv.fr Sirene in PostgreSQL with API REST","archived":false,"fork":false,"pushed_at":"2020-05-09T20:00:44.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T11:31:23.225Z","etag":null,"topics":["datagouvfr","postgresql","postgrest","rest-api","sirene"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephane-klein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-09T08:55:44.000Z","updated_at":"2024-07-17T20:55:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4bc910a9-cf38-45a8-999e-593ef8feb4e5","html_url":"https://github.com/stephane-klein/data-gouv-sirene-postgres-postgrest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-klein%2Fdata-gouv-sirene-postgres-postgrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-klein%2Fdata-gouv-sirene-postgres-postgrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-klein%2Fdata-gouv-sirene-postgres-postgrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-klein%2Fdata-gouv-sirene-postgres-postgrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephane-klein","download_url":"https://codeload.github.com/stephane-klein/data-gouv-sirene-postgres-postgrest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245056902,"owners_count":20553854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datagouvfr","postgresql","postgrest","rest-api","sirene"],"created_at":"2024-11-29T22:17:20.317Z","updated_at":"2026-04-16T08:34:21.645Z","avatar_url":"https://github.com/stephane-klein.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Import data.gouv.fr Sirene in PostgreSQL with API REST\n\nStatus: Work in Progress, see [issues](https://github.com/stephane-klein/poc-data-gouv-siren-postgres/issues)\n\nImport [Sirene](https://files.data.gouv.fr/insee-sirene/) data from [data.gouv.fr](https://www.data.gouv.fr) website to [PostgreSQL](postgresql.org/).\n\n[PostgREST](http://postgrest.org) service is used to provide Sirene [API REST](https://en.wikipedia.org/wiki/Representational_state_transfer).\n\n## Importation notes\n\nConsidering that the file `StockUniteLegale_utf8.csv` is very big `2.6G` then some filters are applied before importation:\n\n- drop `Cessée` [`etatAdministratifUniteLegale`](https://www.sirene.fr/sirene/public/variable/etatAdministratifUniteLegale)\n- use `--ape-filter` to apply a filter on [`APE` code](https://www.sirene.fr/sirene/public/variable/activitePrincipaleUniteLegale)\n\n## Prerequisites\n\n- [Docker Engine](https://docs.docker.com/engine/)\n- [Docker Compose](https://docs.docker.com/compose/)\n- [Python3](https://www.python.org/)\n\n[Homebrew](https://brew.sh/index_fr) instructions:\n\n```sh\n$ brew cask install docker\n$ brew install python3 curl\n```\n\n## Getting started\n\nDownload data from https://files.data.gouv.fr/insee-sirene/:\n\n```\n$ ./scripts/download-data.sh\n```\n\nStart and initialize PostgreSQL database:\n\n```\n$ ./scripts/up.sh\n```\n\nSetup Python environment:\n\n```\n$ python3 -m venv .venv\n$ source .venv/bin/activate\n$ pip install -r requirements.txt\n```\n\nImport `StockUniteLegale_utf8.csv` file to PostgreSQL database:\n\n```\n$ ./import-csv-to-postgres.py --csv datas/StockUniteLegale_utf8.csv --db postgresql://postgres:password@127.0.0.1/postgres --ape-filter 62.01Z\n```\n\nStart REST API server (based on [PostgREST](http://postgrest.org)):\n\n```\n$ docker-compose up -d\n```\n\nUrls:\n\n- REST API: http://127.0.0.1:3000/\n- Swagger doc: http://127.0.0.1:8080/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephane-klein%2Fdata-gouv-sirene-postgres-postgrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephane-klein%2Fdata-gouv-sirene-postgres-postgrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephane-klein%2Fdata-gouv-sirene-postgres-postgrest/lists"}