# Get stats

`GET https://api.cryptohopper.com/v1/hopper/{id}/stats`

Part of [Hoppers](https://www.cryptohopper.com/api-documentation/api-reference/hoppers.md) in the Cryptohopper API reference.

Returns the stats page data of the hopper for a period: buys and sells per day, most traded currencies, average profit and holding time per currency and trigger, daily profits, allocation of funds, value history, open position stats and current balances.

OAuth scope: `read`

Timestamps inside the chart series are in milliseconds. buysandsells holds the buy series first and the sell series second. Holding times are in seconds. Empty lists are returned as null.

## Headers

| Name | Type | Required | Description |
|---|---|---|---|
| `access-token` | string | yes | The OAuth access token of the user. |

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | Hopper ID. |

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `daterange` | string | no | Period as two Unix timestamps joined by a dash, e.g. 1757548800-1758758400. Default the last two weeks. |

## Example request

```bash
curl "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/stats" \
  -H "access-token: YOUR_ACCESS_TOKEN"
```

## Response

Example response (illustrative values):

```json
{
    "data": {
        "date_range": "1757548800-1758758400",
        "start_time": 1757548800,
        "end_time": 1758758400,
        "buysandsells": [
            [
                [
                    1758499200000,
                    4
                ]
            ],
            [
                [
                    1758499200000,
                    3
                ]
            ]
        ],
        "mosttraded": {
            "BTC": 12,
            "ETH": 8
        },
        "average_holding_time": {
            "ETH": 14220,
            "BTC": 18234.5
        },
        "average_profit": {
            "BTC": 1.52,
            "ETH": 0.87
        },
        "profits_sell_triggers": {
            "Take Profit": 1.8
        },
        "profits_sell_triggers_total": 10,
        "profits_sell_triggers_counts": {
            "Take Profit": 10
        },
        "profits_buy_triggers": {
            "Strategy": 1.4
        },
        "profits_buy_triggers_total": 10,
        "profits_buy_triggers_counts": {
            "Strategy": 10
        },
        "daily_profits": [
            [
                1758499200000,
                1.35
            ],
            [
                1758585600000,
                0
            ]
        ],
        "allocation_of_funds": {
            "available": "45.20",
            "in open positions": "50.10",
            "reserved": "4.70"
        },
        "currentinassets": [
            [
                1758754800000,
                "1523.45"
            ]
        ],
        "currentusdinassets": [
            [
                1758754800000,
                "1523.45"
            ]
        ],
        "average_profit_total": 1.26,
        "average_holding_time_total": 16500.2,
        "totaltraded": 20,
        "returns": null,
        "total_returns": "1285.2000000000000000",
        "invested": null,
        "total_invested": "1250.0000000000000000",
        "positions": "812.5000000000000000",
        "profit": null,
        "invest": null,
        "fees": "3.1000000000000000",
        "profitstats": {
            "total_returns": "472.70",
            "total_invest": "1250.00",
            "total_positions": "812.50",
            "total_fees": "3.10"
        },
        "stats_open_positions": {
            "per_cur_totals": {
                "BTC": {
                    "holds": "5 hours",
                    "percs": "1.25",
                    "poss": "2",
                    "costs": "150.00"
                }
            },
            "other_coins": null,
            "data": [
                {
                    "label": "BTC",
                    "data": 15187500000
                }
            ],
            "total_costs": "150.00",
            "average_perc": "1.25",
            "average_hold": "5 hours",
            "total_pos": 2
        },
        "assets": {
            "USDT": 1250.45,
            "BTC": 0.0025
        }
    }
}
```

Status codes: 200. Errors return JSON with `status`, `error` and `message`, plus a numeric `code` when the error comes from the API itself rather than the gateway.
