Funding information API

Server-side REST API

The server side rest API allows retrieving information about the listed products. Use this API in your own website to

  • Show the funding progress of your campaigns

  • Add a component that shows recent investments on your platform

Use the following URL in your browser to test the API response: https://staging.cashlink-staging.de/api/external-info/

The response will look like this:

GET <server URL TBD>/api/external-info/
{
"user": null,
"products": [
{
"name": "Issuer issuer 1 Token",
"type": "DIGITAL_COMPANY_SHARE",
"volume": {"amount": "500000000", "decimals": 3, "currency": "EUR"},
"investment_sum": {"amount": "41000000", "decimals": 3, "currency": "EUR"},
"investment_count": 2,
"recent_investments": [
{
"signed_date": "2020-07-14T17:07:08.243552Z",
"amount": {"amount": "1000000", "decimals": 3, "currency": "EUR"},
"postal_code": null
},
{
"signed_date": "2020-07-14T16:40:07.673258Z",
"amount": {"amount": "40000000", "decimals": 3, "currency": "EUR"},
"postal_code": "12345"
}
]
},
{
"name": "Issuer issuer 2 Token",
"type": "BOND",
"volume": {"amount": "500000000", "decimals": 3, "currency": "EUR"},
"investment_sum": {"amount": "40000000", "decimals": 3, "currency": "EUR"},
"investment_count": 1,
"recent_investments": [
{
"signed_date": "2020-07-14T16:40:20.461359Z",
"amount": {"amount": "40000000", "decimals": 3, "currency": "EUR"},
"postal_code": "12345"
}
]
}
]
}

Notes

Monetary values are represented as a combination of amount, decimals & currency. For example, {"amount": "40000000", "decimals": 3, "currency": "EUR"} means "40000.000 EUR"

Client-side API

Via the client-side API, you can retrieve information on your own website about the user currently logged in. Use this API to

  • Show the login status of your users when visiting your website

  • Adapt certain areas of your website based on the login status

User information can be retrieved client-side via postMessage:

<pre id="info">
<pre>
<iframe style="visibility: hidden; display: none" id=frame src="https://staging.cashlink-staging.de/external-info"></iframe>
<script>
let origin = 'https://staging.cashlink-staging.de';
let el = document.getElementById('frame');
function printInfo(user) {
let msg;
if (user) {
msg = `Name: ${user.name}\nE-Mail: ${user.email}`;
} else {
msg = "Not logged in";
}
document.getElementById('info').innerText = msg;
}
el.addEventListener('load', () => {
window.addEventListener('message', (evt) => {
if (evt.origin == origin) {
let res = evt.data;
console.log('response:', res);
if (res.success && res.result.user) {
printInfo(res.result.user);
} else {
printInfo(null);
}
}
});
el.contentWindow.postMessage({method: 'getExternalInfo'}, origin);
});
</script>

The response in the success case will be of the format

{
"success": true,
"result": {
"user": {"email": "foo@bar.baz", "name": "Maria Mustermann"},
"products": [/*... <same as for server-side API>*/]
}
}

In the failure case, the response format will be

{
"success": false,
"error": "could not fetch data"
}

This can only occur when Cashlink servers are not reachable. If the user is not logged in, the response will be

{
"success": true,
"result": {"user": null, "products": [/*...*/]}
}