# human\_protocol\_sdk.statistics.statistics\_client module

This client enables to obtain statistical information from the subgraph.

## Code Example

```python
from human_protocol_sdk.constants import ChainId
from human_protocol_sdk.statistics import StatisticsClient

statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)
```

## Module

### *class* human\_protocol\_sdk.statistics.statistics\_client.DailyEscrowData(timestamp, escrows\_total, escrows\_pending, escrows\_solved, escrows\_paid, escrows\_cancelled)

Bases: `object`

A class used to specify daily escrow data.

#### \_\_init\_\_(timestamp, escrows\_total, escrows\_pending, escrows\_solved, escrows\_paid, escrows\_cancelled)

Initializes a DailyEscrowData instance.

* **Parameters:**
  * **timestamp** (`datetime`) – Timestamp
  * **escrows\_total** (`int`) – Total escrows
  * **escrows\_pending** (`int`) – Pending escrows
  * **escrows\_solved** (`int`) – Solved escrows
  * **escrows\_paid** (`int`) – Paid escrows
  * **escrows\_cancelled** (`int`) – Cancelled escrows

### *class* human\_protocol\_sdk.statistics.statistics\_client.DailyHMTData(timestamp, total\_transaction\_amount, total\_transaction\_count, daily\_unique\_senders, daily\_unique\_receivers)

Bases: `object`

A class used to specify daily HMT data.

#### \_\_init\_\_(timestamp, total\_transaction\_amount, total\_transaction\_count, daily\_unique\_senders, daily\_unique\_receivers)

Initializes a DailyHMTData instance.

* **Parameters:**
  * **timestamp** (`datetime`) – Timestamp
  * **total\_transaction\_amount** (`int`) – Total transaction amount
  * **total\_transaction\_count** (`int`) – Total transaction count
  * **daily\_unique\_senders** (`int`) – Total unique senders
  * **daily\_unique\_receivers** (`int`) – Total unique receivers

### *class* human\_protocol\_sdk.statistics.statistics\_client.DailyPaymentData(timestamp, total\_amount\_paid, total\_count, average\_amount\_per\_worker)

Bases: `object`

A class used to specify daily payment data.

#### \_\_init\_\_(timestamp, total\_amount\_paid, total\_count, average\_amount\_per\_worker)

Initializes a DailyPaymentData instance.

* **Parameters:**
  * **timestamp** (`datetime`) – Timestamp
  * **total\_amount\_paid** (`int`) – Total amount paid
  * **total\_count** (`int`) – Total count
  * **average\_amount\_per\_worker** (`int`) – Average amount per worker

### *class* human\_protocol\_sdk.statistics.statistics\_client.DailyWorkerData(timestamp, active\_workers)

Bases: `object`

A class used to specify daily worker data.

#### \_\_init\_\_(timestamp, active\_workers)

Initializes a DailyWorkerData instance.

* **Parameters:**
  * **timestamp** (`datetime`) – Timestamp
  * **active\_workers** (`int`) – Active workers

### *class* human\_protocol\_sdk.statistics.statistics\_client.EscrowStatistics(total\_escrows, daily\_escrows\_data)

Bases: `object`

A class used to specify escrow statistics.

#### \_\_init\_\_(total\_escrows, daily\_escrows\_data)

Initializes a EscrowStatistics instance.

* **Parameters:**
  * **total\_escrows** (`int`) – Total escrows
  * **daily\_escrows\_data** (`List`\[[`DailyEscrowData`](#human_protocol_sdk.statistics.statistics_client.DailyEscrowData)]) – Daily escrows data

### *class* human\_protocol\_sdk.statistics.statistics\_client.HMTHolder(address, balance)

Bases: `object`

A class used to specify HMT holder.

#### \_\_init\_\_(address, balance)

Initializes a HMTHolder instance.

* **Parameters:**
  * **address** (`str`) – Holder address
  * **balance** (`int`) – Holder balance

### *class* human\_protocol\_sdk.statistics.statistics\_client.HMTHoldersParam(address=None, order\_direction='asc')

Bases: `object`

A class used to specify parameters for querying HMT holders.

#### \_\_init\_\_(address=None, order\_direction='asc')

Initializes a HMTHoldersParam instance.

* **Parameters:**
  * **address** (`Optional`\[`str`]) – Filter by holder’s address
  * **order\_direction** (`str`) – Optional. Direction of sorting (‘asc’ for ascending, ‘desc’ for descending)

### *class* human\_protocol\_sdk.statistics.statistics\_client.HMTStatistics(total\_transfer\_amount, total\_transfer\_count, total\_holders)

Bases: `object`

A class used to specify HMT statistics.

#### \_\_init\_\_(total\_transfer\_amount, total\_transfer\_count, total\_holders)

Initializes a HMTStatistics instance.

* **Parameters:**
  * **total\_transfer\_amount** (`int`) – Total transfer amount
  * **total\_transfer\_count** (`int`) – Total transfer count
  * **total\_holders** (`int`) – Total holders

### *class* human\_protocol\_sdk.statistics.statistics\_client.PaymentStatistics(daily\_payments\_data)

Bases: `object`

A class used to specify payment statistics.

#### \_\_init\_\_(daily\_payments\_data)

Initializes a PaymentStatistics instance.

* **Parameters:** **daily\_payments\_data** (`List`\[[`DailyPaymentData`](#human_protocol_sdk.statistics.statistics_client.DailyPaymentData)]) – Daily payments data

### *class* human\_protocol\_sdk.statistics.statistics\_client.StatisticsClient(chain\_id=ChainId.POLYGON\_AMOY)

Bases: `object`

A client used to get statistical data.

#### \_\_init\_\_(chain\_id=ChainId.POLYGON\_AMOY)

Initializes a Statistics instance

* **Parameters:** **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.1.5/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Chain ID to get statistical data from

#### get\_escrow\_statistics(filter=\<human\_protocol\_sdk.filter.StatisticsFilter object>)

Get escrow statistics data for the given date range.

* **Parameters:** **filter** ([`StatisticsFilter`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.1.5/human_protocol_sdk.filter#human_protocol_sdk.filter.StatisticsFilter)) – Object containing the date range
* **Return type:** [`EscrowStatistics`](#human_protocol_sdk.statistics.statistics_client.EscrowStatistics)
* **Returns:** Escrow statistics data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient
  from human_protocol_sdk.filter import StatisticsFilter

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_escrow_statistics())
  print(
      statistics_client.get_escrow_statistics(
          StatisticsFilter(
              date_from=datetime.datetime(2023, 5, 8),
              date_to=datetime.datetime(2023, 6, 8),
          )
      )
  )
  ```

#### get\_hmt\_daily\_data(filter=\<human\_protocol\_sdk.filter.StatisticsFilter object>)

Get HMT daily statistics data for the given date range.

* **Parameters:** **filter** ([`StatisticsFilter`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.1.5/human_protocol_sdk.filter#human_protocol_sdk.filter.StatisticsFilter)) – Object containing the date range
* **Return type:** `List`\[[`DailyHMTData`](#human_protocol_sdk.statistics.statistics_client.DailyHMTData)]
* **Returns:** HMT statistics data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient, StatisticsFilter

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_hmt_daily_data())
  print(
      statistics_client.get_hmt_daily_data(
          StatisticsFilter(
              date_from=datetime.datetime(2023, 5, 8),
              date_to=datetime.datetime(2023, 6, 8),
          )
      )
  )
  ```

#### get\_hmt\_holders(param=\<human\_protocol\_sdk.statistics.statistics\_client.HMTHoldersParam object>)

Get HMT holders data with optional filters and ordering.

* **Parameters:** **param** ([`HMTHoldersParam`](#human_protocol_sdk.statistics.statistics_client.HMTHoldersParam)) – Object containing filter and order parameters
* **Return type:** `List`\[[`HMTHolder`](#human_protocol_sdk.statistics.statistics_client.HMTHolder)]
* **Returns:** List of HMT holders
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient, HMTHoldersParam

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_hmt_holders())
  print(
      statistics_client.get_hmt_holders(
          HMTHoldersParam(
              address="0x123...",
              order_direction="asc",
          )
      )
  )
  ```

#### get\_hmt\_statistics()

Get HMT statistics data.

* **Return type:** [`HMTStatistics`](#human_protocol_sdk.statistics.statistics_client.HMTStatistics)
* **Returns:** HMT statistics data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_hmt_statistics())
  ```

#### get\_payment\_statistics(filter=\<human\_protocol\_sdk.filter.StatisticsFilter object>)

Get payment statistics data for the given date range.

* **Parameters:** **filter** ([`StatisticsFilter`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.1.5/human_protocol_sdk.filter#human_protocol_sdk.filter.StatisticsFilter)) – Object containing the date range
* **Return type:** [`PaymentStatistics`](#human_protocol_sdk.statistics.statistics_client.PaymentStatistics)
* **Returns:** Payment statistics data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient
  from human_protocol_sdk.filter import StatisticsFilter

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_payment_statistics())
  print(
      statistics_client.get_payment_statistics(
          StatisticsFilter(
              date_from=datetime.datetime(2023, 5, 8),
              date_to=datetime.datetime(2023, 6, 8),
          )
      )
  )
  ```

#### get\_worker\_statistics(filter=\<human\_protocol\_sdk.filter.StatisticsFilter object>)

Get worker statistics data for the given date range.

* **Parameters:** **filter** ([`StatisticsFilter`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.1.5/human_protocol_sdk.filter#human_protocol_sdk.filter.StatisticsFilter)) – Object containing the date range
* **Return type:** [`WorkerStatistics`](#human_protocol_sdk.statistics.statistics_client.WorkerStatistics)
* **Returns:** Worker statistics data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.statistics import StatisticsClient
  from human_protocol_sdk.filter import StatisticsFilter

  statistics_client = StatisticsClient(ChainId.POLYGON_AMOY)

  print(statistics_client.get_worker_statistics())
  print(
      statistics_client.get_worker_statistics(
          StatisticsFilter(
              date_from=datetime.datetime(2023, 5, 8),
              date_to=datetime.datetime(2023, 6, 8),
          )
      )
  )
  ```

### *exception* human\_protocol\_sdk.statistics.statistics\_client.StatisticsClientError

Bases: `Exception`

Raises when some error happens when getting data from subgraph.

### *class* human\_protocol\_sdk.statistics.statistics\_client.WorkerStatistics(daily\_workers\_data)

Bases: `object`

A class used to specify worker statistics.

#### \_\_init\_\_(daily\_workers\_data)

Initializes a WorkerStatistics instance.

* **Parameters:** **daily\_workers\_data** (`List`\[[`DailyWorkerData`](#human_protocol_sdk.statistics.statistics_client.DailyWorkerData)]) – Daily workers data
