# Data Union Observation

{% hint style="info" %}
**Observation functions** for your data union are **provided by the** [**data union client**](https://www.npmjs.com/package/@dataunions/client)**.**

You can get stats regarding **your members and the earnings** connected to your Data Union.
{% endhint %}

### Get Data Union stats

```typescript
const dataUnion = await DU.getDataUnion(
    DATA_UNION_CONTRACT_ADDRESS
);

const stats = await dataUnion.getStats()
```

The **returned stats object** would look something like this:

<pre class="language-typescript"><code class="lang-typescript"><strong>{
</strong><strong>    "activeMemberCount": BigNumber {_hex: '0x00', _isBigNumber: true}
</strong>    "inactiveMemberCount": BigNumber {_hex: '0x00', _isBigNumber: true}
    "joinPartAgentCount": BigNumber {_hex: '0x02', _isBigNumber: true}
    "lifetimeMemberEarnings": BigNumber {_hex: '0x00', _isBigNumber: true}
    "totalAdminFees": BigNumber {_hex: '0x00', _isBigNumber: true}
    "totalDataUnionFees": BigNumber {_hex: '0x00', _isBigNumber: true}
    "totalEarnings": BigNumber {_hex: '0x00', _isBigNumber: true}
    "totalRevenue": BigNumber {_hex: '0x00', _isBigNumber: true}
    "totalWithdrawable": BigNumber {_hex: '0x00', _isBigNumber: true}
}
</code></pre>

### Other relevant query functions are:

<pre class="language-typescript"><code class="lang-typescript">dataUnion.getActiveMemberCount();

// returns contract address of the data union
dataUnion.getAddress();

dataUnion.getAdminAddress();

// Get data union admin fee fraction (between 0.0 and 1.0) that admin gets from each revenue event
dataUnion.getAdminFee();

dataUnion.getChainName();

dataUnion.getMemberStats("$memberAddress")
/** 
returns:
{
<strong>    earningsBeforeLastJoin: BigNumber {_hex: '0x00', _isBigNumber: true}
</strong>    status: "ACTIVE"
    totalEarnings: BigNumber {_hex: '0x00', _isBigNumber: true}
    withdrawableEarnings: BigNumber {_hex: '0x00', _isBigNumber: true}
}
*/

dataUnion.getMetadata();

dataUnion.getNewMemberStipend();

dataUnion.getWithdrawableEarnings("$memberAddress");
</code></pre>

If you deployed with Streamr the [Streamr Core](https://streamr.network/core) app **provides monitoring functions for Admins**, showing subscriber numbers, total revenue, join requests and more.

### Managing the Data Union

**Data unions are listed along with the data products in** [**Core > Products**](https://streamr.network/core/products). Data unions are marked by a data union badge and a members badge showing the current amount of approved members. Click the tile menu to access the data union stats and manage members.

**The stats view provides an overview** of the data union as well as its members and subscribers over time. The members view **allows you to manage manual member join requests** (requests that did not contain a shared secret).
