# Estimate Lithos hashrate

`GET /stats/mining/hashrate` · Lithos client API · Statistics

Source: https://lithosprotocol.org/docs/api/get-mining-hashrate

Estimates the hashrate behind Lithos blocks: the network difficulty of every confirmed block
carrying a configured Lithos genesis, added up and divided by the seconds covered. A chain
block counts once however many genesis transactions it holds. This measures the miners
producing those blocks — not this client's workers, and not all of Ergo. Claimed NISP scores
are never used.

Range and interval rules match `/stats/mining/buckets`. The returned `from` and `until` are
the period actually covered once clipped to retained history and the processed tip, and
`partial` says the request reached past it. With no work or no usable time the status is
`insufficient-data` and `hashesPerSecond` is left out rather than reported as zero; fewer
than 20 sampled blocks is `sparse`. Read both `status` and `sourceStatus` — sampling quality
and data freshness are different things.

`relativeSamplingError` is 1 / sqrt(sampleCount), which assumes blocks arrive as a Poisson
process. It is a rough relative error, not a confidence interval, and it says nothing about
whether miner participation held steady. Compare short or sparse windows carefully.

## Parameters

| Name | In | Type | Required | Description |

|---|---|---|---|---|

| `from` | query | integer · int64 | yes | Inclusive start in Unix milliseconds, on a UTC hour or day boundary to match `interval`. |

| `until` | query | integer · int64 | yes | Exclusive end in Unix milliseconds. On the same boundary, later than `from`, and at most 500 intervals after it. |

| `interval` | query | string | no | Bucket size. Both range boundaries must be a whole number of these since the Unix epoch. |

## Responses

### 200: An estimate, or an explicit insufficient-data result, with coverage and sample count.

`LithosHashrateEstimate`

- `status` (string, required, one of insufficient-data, sparse, estimated): Sampling quality, separate from source freshness. `sparse` means fewer than 20 sampled blocks.
- `sourceStatus` (string, required, one of disabled, loading, ready, stale, unavailable, catching-up, recovering): How far collection has got. `ready` means it reached the last checked chain tip. `catching-up` and `recovering` mean replay or reorg work is still running, `stale` means the last successful check is too old, and `unavailable` means collection failed. On `disabled` or `loading` the numbers are not evidence that the period was quiet.
- `source` (MiningCursor, required): The processed chain point a statistics result was read from.
  - `height` (integer, required)
  - `blockId` (string, required)
  - `parentId` (string, required)
  - `timestamp` (integer · int64, required): The block's own timestamp in Unix milliseconds, not the time the client read it.
- `from` (integer · int64, required): Start of the covered period in Unix milliseconds, clipped to retained history.
- `until` (integer · int64, required): End of the covered period in Unix milliseconds, clipped to the processed tip. Equals `from` when no usable time is left.
- `sampleCount` (integer · int64, required): Distinct chain blocks in the selected buckets that carried a configured Lithos genesis.
- `difficultySum` (string, required): An exact nonnegative integer as a decimal string. Parse it without going through a float.
- `hashesPerSecond` (string): The estimate in whole hashes per second. Left out rather than reported as zero when there is not enough data.
- `relativeSamplingError` (number · double): Rough relative standard error, 1 / sqrt(sampleCount). 0.2 means about 20%. Omitted with zero samples.
- `partial` (boolean, required): Whether the requested range reaches past retained coverage.
- `population` (string, required, one of miners-producing-configured-lithos-genesis)
- `formula` (string, required, one of sum-confirmed-lithos-block-difficulty/covered-seconds)

### 400: A timestamp is missing, malformed, off a bucket boundary, or the range is too long; or `interval` is not hour or day.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 503: History is loading, disabled, busy, or unreadable. Check `mining.status` in /stats before retrying.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X GET "http://localhost:9000/stats/mining/hashrate?from=0&until=1"
```

## Example response

```json
{
  "status": "insufficient-data",
  "sourceStatus": "disabled",
  "source": {
    "height": 0,
    "blockId": "string",
    "parentId": "string",
    "timestamp": 0
  },
  "from": 0,
  "until": 0,
  "sampleCount": 0,
  "difficultySum": "1000000000",
  "hashesPerSecond": "0",
  "relativeSamplingError": 0,
  "partial": true,
  "population": "miners-producing-configured-lithos-genesis",
  "formula": "sum-confirmed-lithos-block-difficulty/covered-seconds"
}
```
