solidaires-informatique / sirene
Retrieves company and establishment data from the SIRENE's Insee API
Requires
- php: >=8.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.68
- mockery/mockery: ^1.6
- pestphp/pest: ^3.7
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- tomasvotruba/cognitive-complexity: ^1.0
README
Retrieves company and establishment data from the SIRENE's Insee API
Usage
Code
Method on Sirene's instances:
rawSiret(string $siret): array
to get data from the API as arraysiret(string $siret): Etablissement
to get data from the API asEtablissement
rawSiren(string $siren): array
to get data from the API as arraysiren(string $siren): UniteLegale
to get data from the API asUniteLegale
Example:
$workplace = (new Sirene(apiKey: 'SUPER-SECRET-API-KEY'))->siret('13000766900018');
echo (string) $workplace->address;
Get an API KEY
You'll need an account on https://portail-api.insee.fr/ (“connexion pour les externes”):
1) Create an application in https://portail-api.insee.fr/applications/creation (choose a name and fill the description field) 2) Select "Simple" in the "Sécurité" step. 3) Left the client id empty 4) Select "API Sirene" in the "Souscription" step and click on "Souscrire". 5) Select your application in https://portail-api.insee.fr/applications/mine and go to "Subscriptions" 6) Select "API Sirene", retrieve your API key.
Issues, suggestions and contributions
Please open an issue at https://gitlab.com/solidaires-informatique/sirene/-/issues
Dev tools
Code style verifications:
vendor/bin/php-cs-fixer fix --dry-run -v --diff
Static analysis:
vendor/bin/phpstan analyse --memory-limit=250M
Tests:
./vendor/bin/pest
To run RealTest
that really call the Insee's API you'll need an API key from Insee :
1) Retrieve an API KEY (follow "Auth" part of README)
2) Copy phpunit.xml.dist
to phpunit.xml
.
3) Fill the API_KEY with your key.
Licence
Licensed under GNU Affero General Public License v3.0 (AGPL-3.0), read more at https://choosealicense.com/licenses/agpl-3.0/