Example of fund profile data with authorization

Fund profile data realized with PHP (with authorization)

This PHP based example fetches the fund profile API endpoint for a secured fund by cURL and places all parts in a HTML structure.

HANSAsecur

ISIN: DE0008479023 / WKN: 847902

Status: 16.03.2023

Fund category Umbrella fund
Inception date 02.01.1970
Currency EUR
Fund assets 98432444.7000 EUR
Total fund assets 98432444.7000 EUR
End of fiscal year Dec 31
Dividend distribution distributing
Conformity yes
Issue surcharge 5 %
Redemption fee 0 %
TER (total expense ratio) 1,58 % p.a.
incl. management fee 1,5 % p.a.
incl. custodian bank fee 0,05 % p.a.
Performance fee no
Savings plan yes
One-time investment yes
Capital-forming payments yes (min. 34.00 EUR)
all fund details
<?php

// Get cURL resource
$curl = curl_init();

$username = 'test-username';
$password = 'test-password';

$hash = base64_encode($username . ':' . $password);

// Set some options - we are passing in a useragent and some HTTP headers
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL            => 'https://api.hansainvest.com/api/v1/profile/DE0008479023/',
    CURLOPT_USERAGENT      => 'Sample cURL Request',
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'Accept-Language: de',
        'Authorization: Basic ' . $hash,  // necessary for authentication
    ],
]);

// Send the request & save response to $respJson
$respJson    = curl_exec($curl);
$fundProfile = json_decode($respJson);

// Close request to clear up some resources
curl_close($curl);

?>

<h3 class="hi-profile-name"><?php echo $fundProfile->fund->name; ?></h3>
<h4 class="hi-profile-isin">ISIN: <?php echo $fundProfile->fund->isin; ?> /
    WKN: <?php echo $fundProfile->fund->wkn; ?></h4>
<p><small>Stand: <?php echo date(
            'd.m.Y',
            strtotime($fundProfile->fund->status_date)
        ); ?></small></p>
<table class="table hi-profile">
    <tbody>
    <tr>
        <th scope="row">Fondskategorie</th>
        <td class="hi-profile-fund_category"><?php echo $fundProfile->fund->category; ?></td>
    </tr>
    <tr>
        <th scope="row">Auflagedatum</th>
        <td class="hi-profile-fund_inception_date"><?php echo date(
                'd.m.Y',
                strtotime($fundProfile->fund->fund_inception_date)
            ); ?></td>
    </tr>
    <tr>
        <th scope="row">Fondswährung</th>
        <td class="hi-profile-currency"><?php echo $fundProfile->fund->currency; ?></td>
    </tr>
    <tr>
        <th scope="row">Fondsvermögen</th>
        <td class="hi-profile-fund_assets"><?php echo $fundProfile->fund->fund_assets; ?></td>
    </tr>
    <tr>
        <th scope="row">Gesamtfondsvermögen</th>
        <td class="hi-profile-total_fund_assets"><?php echo $fundProfile->fund->total_fund_assets; ?></td>
    </tr>
    <tr>
        <th scope="row">Geschäftsjahresende</th>
        <td class="hi-profile-end_of_fiscal_year"><?php echo $fundProfile->fund->end_of_fiscal_year; ?></td>
    </tr>
    <tr>
        <th scope="row">Ertragsverwendung</th>
        <td class="hi-profile-dividend_distributions"><?php echo $fundProfile->fund->distributing; ?></td>
    </tr>
    <tr>
        <th scope="row">UCITS-konform</th>
        <td class="hi-profile-conformity"><?php echo $fundProfile->fund->conformity ? 'ja' : 'nein'; ?></td>
    </tr>
    <tr>
        <th scope="row">Ausgabeaufschlag</th>
        <td class="hi-profile-issue_surcharge"><?php echo $fundProfile->fund->issue_surcharge; ?></td>
    </tr>
    <tr>
        <th scope="row">Rücknahmeabschlag</th>
        <td class="hi-profile-redemption_fee"><?php echo $fundProfile->fund->redemption_fee; ?></td>
    </tr>
    <tr>
        <th scope="row">TER (= laufende Kosten)</th>
        <td class="hi-profile-total_expense_ratio"><?php echo $fundProfile->fund->total_expense_ratio; ?> % p.a.</td>
    </tr>
    <tr>
        <th scope="row"> inkl. Verwaltungsvergütung</th>
        <td class="hi-profile-management_fee"><?php echo $fundProfile->fund->management_fee; ?> % p.a.</td>
    </tr>
    <tr>
        <th scope="row"> inkl. Verwahrstellenvergütung</th>
        <td class="hi-profile-custodian_bank_fee"><?php echo $fundProfile->fund->custodian_bank_fee; ?> % p.a.</td>
    </tr>
    <tr>
        <th scope="row">Erfolgsvergütung</th>
        <td class="hi-profile-performance_fee"><?php echo $fundProfile->fund->performance_fee ? 'ja' : 'nein'; ?></td>
    </tr>
    <tr>
        <th scope="row">Sparplan</th>
        <td class="hi-profile-savings_plan">
            <?php
            if ($fundProfile->fund->savings_plan->possible) {
                echo 'ja';

                if ($fundProfile->fund->savings_plan->minimum_investment) {
                    echo $fundProfile->fund->savings_plan->minimum_investment;
                }
            } else {
                echo 'nein';
            }
            ?>
        </td>
    </tr>
    <tr>
        <th scope="row">Einzelanlage</th>
        <td class="hi-profile-one_time_investment">
            <?php
            if ($fundProfile->fund->one_time_investment->possible) {
                echo 'ja';

                if ($fundProfile->fund->one_time_investment->minimum_investment) {
                    echo $fundProfile->fund->one_time_investment->minimum_investment;
                }
            } else {
                echo 'nein';
            }
            ?>
        </td>
    </tr>
    <tr>
        <th scope="row">VL-fähig</th>
        <td class="hi-profile-capital_forming_payments">
            <?php
            if ($fundProfile->fund->capital_forming_payments->possible) {
                echo 'ja';

                if ($fundProfile->fund->capital_forming_payments->minimum_investment) {
                    echo $fundProfile->fund->capital_forming_payments->minimum_investment;
                }
            } else {
                echo 'nein';
            }
            ?>
        </td>
    </tr>
    </tbody>
</table>
<a class="hi-profile-link" href="<?php echo $fundProfile->fund->url; ?>">alle Fondsdetails</a>