solidaires-informatique / sirene
Retrieves company and establishment data from the SIRENE's Insee API
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.26
- mockery/mockery: ^1.6
- pestphp/pest: ^2.18
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- tomasvotruba/cognitive-complexity: ^0.2
README
Retrieves company and establishment data from the SIRENE's Insee API
Usage
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:
$accessToken = AccessToken::get('SAbQGvuIEcfB8uOElaI2rkdINvAa', 'LLhFGsUWlnbDx8T9n_PINwqGZywa');
$workplace = (new Sirene($accessToken))->siret('13000766900018');
echo (string) $workplace->address;
Tip: you can cache the AccessToken for the time given in the expiresIn property.
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 allow AccessTokenTest to run you need API keys from Insee :
1) Create an account at https://api.insee.fr/catalogue/.
2) Copy phpunit.xml.dist
to phpunit.xml
.
3) Fill the API_KEY and API_SECRET with values given in "Mes applications".
Licence
Licensed under GNU Affero General Public License v3.0 (AGPL-3.0), read more at https://choosealicense.com/licenses/agpl-3.0/