rikukukkaniemi / finnish-company-info
Get Finnish company information using business ID (y-tunnus)
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/rikukukkaniemi/finnish-company-info
Requires
- php: >=8.2
- ext-ctype: *
- ext-iconv: *
- guzzlehttp/guzzle: ^7.5
- symfony/console: 6.2.*
- symfony/dotenv: 6.2.*
- symfony/flex: ^2
- symfony/framework-bundle: 6.2.*
- symfony/runtime: 6.2.*
- symfony/yaml: 6.2.*
Requires (Dev)
- phpunit/phpunit: ^10.0
- symfony/browser-kit: 6.2.*
- symfony/css-selector: 6.2.*
- symfony/phpunit-bridge: ^6.2
- symplify/easy-coding-standard: ^11.3
Conflicts
This package is auto-updated.
Last update: 2025-10-08 19:47:34 UTC
README
With this PHP library you can easily fetch data on a company given its business ID (y-tunnus):
- Name of the company
- Website
- Current address (street, city, postal code)
- Current main line of business (code and textual description)
Library uses https://avoindata.prh.fi/ytj_en.html as the data source.
Installation
You can require library with:
composer require rikukukkaniemi/finnish-company-info
See requirements from Packagist.
How to use
Here is an example on how to use the library:
public function example(CompanyInfoService $companyInfoService): void
{
try {
$companyInfo = $companyInfoService->getCompanyInformation('1234567-8');
} catch (CompanyInfoException) {
// Handle exception
return;
}
$companyInfo->getName(); // String
$companyInfo->getWebsite(); // String or null
$currentAddress = $companyInfo->getCurrentAddress(); // Address object
$currentAddress->getStreet(); // String
$currentAddress->getCity(); // String
$currentAddress->getPostalCode(); // String
$businessLines = $companyInfo->getBusinessLines(); // Array of BusinessLine objects (can be empty)
$businessLines[0]->getCode(); // String
$businessLines[0]->getDescription(); // String
$businessLines[0]->getLanguage(); // String (language of description)
}
Note that CompanyInfoException is the parent exception. You can also catch a more specific cases of exceptions:
InvalidBusinessIdExceptionwhen business ID seems to be invalid.CompanyNotFoundExceptionwhen company is not found for given business ID.UnexpectedClientDataExceptionwhen the data source returns unexpected data. Should not occur unless data source is broken.
The example code can also be found here.