openapi-php-sdk
openapi-php-sdk copied to clipboard
ETL pipeline: export company data from Openapi to PostgreSQL
Use case
A common ETL scenario: pull company data from the Openapi IT company API and load it into a local PostgreSQL database for reporting or enrichment pipelines.
Example flow
use Openapi\Client;
use Openapi\OauthClient;
$oauth = new OauthClient();
$token = json_decode($oauth->createToken(['GET:company.openapi.com/IT-advanced']), true)['token'];
$client = new Client($token);
$companies = json_decode($client->get('https://company.openapi.com/IT-search', [
'provincia' => 'MI',
'codice_ateco' => '6201',
]), true);
foreach ($companies['items'] as $company) {
$pdo->execute(
'INSERT INTO companies (cf, name, address) VALUES (?, ?, ?) ON CONFLICT DO NOTHING',
[$company['cf'], $company['name'], $company['address']]
);
}
Open questions
- Should the SDK expose a pagination helper or leave that to the consumer?
- How do we handle partial failures mid-batch — retry, skip, or fail fast?
- Is there interest in an official example script for this use case in
examples/?