# Bitcoin Hashrate & Difficulty API
> Bitcoin's network-security and mining-economics layer, live and keyless, powered by mempool.space — hashrate, mining difficulty, the difficulty-adjustment countdown, the halving countdown and per-window block-reward economics. These are the numbers that describe how hard Bitcoin is to mine and how secure the chain is, not a price and not a block explorer. The difficulty endpoint is the flagship: the current mining difficulty plus the live adjustment countdown — how far through the current 2016-block epoch we are, the projected size of the next adjustment (Bitcoin retargets every two weeks so blocks stay ~10 minutes apart), the blocks remaining to the retarget, the estimated retarget date and the realised average block time. The hashrate endpoint returns the current network hashrate in EH/s plus a historical hashrate-and-difficulty timeseries over a chosen window (1m to all). The halving endpoint is the countdown to the next block-subsidy halving — the current block height, the current subsidy in BTC, the next halving block and how many blocks and days remain. The rewards endpoint returns block-reward economics over a recent window: the total miner reward, the fee share, and the per-block averages, all in BTC. This is the Bitcoin difficulty / hashrate / halving cut — distinct from the Bitcoin block-explorer feed (mempool, fees, blocks, addresses, transactions), the mining-pool-distribution feed (who finds the blocks and how centralised), and the multi-coin mining-profitability feed. Hashrate in EH/s, difficulty raw and in trillions, rewards in BTC, times in UTC. No key, nothing stored.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/hashrate-api/..."
```

## Pricing
- **Free** (Free) — 600 calls/Mo, 2 req/s
- **Starter** ($27/Mo) — 28,000 calls/Mo, 6 req/s
- **Pro** ($87/Mo) — 140,000 calls/Mo, 16 req/s
- **Scale** ($239/Mo) — 640,000 calls/Mo, 40 req/s

## Endpoints

### Difficulty

#### `GET /v1/difficulty` — Current difficulty + next-adjustment countdown

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hashrate-api/v1/difficulty"
```

**Response:**
```json
{
    "data": {
        "note": "Bitcoin's mining difficulty and the live difficulty-adjustment countdown. Bitcoin retargets difficulty every 2016 blocks (~2 weeks) so blocks average ~10 minutes: epoch_progress_pct is how far through the current epoch we are, estimated_change_pct the projected size of the next adjustment (positive = mining gets harder), remaining_blocks how many until the retarget, and avg_block_time_seconds the realised block time this epoch (under 600s pushes difficulty up). Live, cached ~60s.",
        "source": "mempool.space public API (v1/difficulty-adjustment), keyless",
        "direction": "easier",
        "remaining_blocks": 160,
        "current_difficulty": 138955357012247.3,
        "epoch_progress_pct": 92.06,
        "previous_change_pct": 1.72,
        "estimated_change_pct": -10.32,
        "next_retarget_height": 953568,
        "avg_block_time_seconds": 669,
        "estimated_retarget_date": "2026-06-14T01:20:55.640Z",
        "current_difficulty_trillions": 138.96
    },
    "meta": {
        "timestamp": "2026-06-12T19:35:55.505Z",
        "request_id": "bae52145-4bdd-409b-aca7-60fc57defa5d"
    },
    "status": "ok",
    "message": "Difficulty retrieved successfully",
    "success": true
}
```

### Hashrate

#### `GET /v1/hashrate` — Network hashrate (EH/s) now and as a timeseries

**Parameters:**
- `period` (query, optional, string) — Window: 1m, 3m, 6m, 1y, 2y, 3y, all Example: `1y`
- `limit` (query, optional, string) — Most-recent points (1-365) Example: `30`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hashrate-api/v1/hashrate?period=1y&limit=30"
```

**Response:**
```json
{
    "data": {
        "note": "Bitcoin's network hashrate — the total computing power securing the chain, in EH/s (exahashes per second) — now and as a daily timeseries over the chosen window. A rising hashrate means more miners and a more secure, harder-to-attack chain. Pass period (1m, 3m, 6m, 1y, 2y, 3y, all; default 1y) and limit (1-365 most-recent points, default 30). Live, cached ~60s.",
        "period": "1y",
        "points": 30,
        "source": "mempool.space public API (v1/mining/hashrate), keyless",
        "history": [
            {
                "date": "2026-06-12T00:00:00.000Z",
                "hashrate_ehs": 932.13
            },
            {
                "date": "2026-06-11T00:00:00.000Z",
                "hashrate_ehs": 852.17
            },
            {
                "date": "2026-06-10T00:00:00.000Z",
                "hashrate_ehs": 860.83
            },
            {
                "date": "2026-06-09T00:00:00.000Z",
                "hashrate_ehs": 898.39
            },
            {
                "date": "2026-06-08T00:00:00.000Z",
                "hashrate_ehs": 806.9
            },
            {
                "date": "2026-06-07T00:00:00.000Z",
                "hashrate_ehs": 830.23
            },
            {
                "date": "2026-06-06T00:00:00.000Z",
                "hashrate_ehs": 926.82
            },
            {
                "date": "2026-06-05T00:00:00.000Z",
                "hashrate_ehs": 990.52
          
…(truncated, see openapi.json for full schema)
```

### Halving

#### `GET /v1/halving` — Countdown to the next block-subsidy halving

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hashrate-api/v1/halving"
```

**Response:**
```json
{
    "data": {
        "note": "The countdown to Bitcoin's next block-subsidy halving. Every 210,000 blocks (~4 years) the reward miners get for each block halves, tightening Bitcoin's issuance — this gives the current block height, the current subsidy in BTC, the next halving's block height, and how many blocks (and roughly how many days, at ~10 min/block) remain. estimated_days_remaining is an approximation from the fixed block target. Live, cached ~60s.",
        "source": "mempool.space public API (blocks/tip/height) + Bitcoin consensus, keyless",
        "progress_pct": 54,
        "current_height": 953408,
        "halvings_so_far": 4,
        "blocks_remaining": 96592,
        "next_subsidy_btc": 1.5625,
        "next_halving_height": 1050000,
        "next_halving_number": 5,
        "estimated_halving_date": "2028-04-13T14:15:55.720Z",
        "estimated_days_remaining": 670.8,
        "current_block_subsidy_btc": 3.125
    },
    "meta": {
        "timestamp": "2026-06-12T19:35:55.720Z",
        "request_id": "4016d40b-ebb5-4c14-8228-aecd405c0145"
    },
    "status": "ok",
    "message": "Halving retrieved successfully",
    "success": true
}
```

### Rewards

#### `GET /v1/rewards` — Block-reward economics over a window of blocks

**Parameters:**
- `blocks` (query, optional, string) — Window size (1-1000) Example: `144`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hashrate-api/v1/rewards?blocks=144"
```

**Response:**
```json
{
    "data": {
        "note": "Block-reward economics over a recent window of blocks: the total miner reward (subsidy + fees) in BTC, how much of it was transaction fees (total_fees_btc and fee_share_pct — fees matter more as the subsidy shrinks), and the per-block averages. Pass blocks (1-1000, default 144 ≈ one day). Live, cached ~60s.",
        "source": "mempool.space public API (v1/mining/reward-stats), keyless",
        "end_block": 953408,
        "start_block": 953265,
        "fee_share_pct": 0.98,
        "window_blocks": 144,
        "total_fees_btc": 4.46120723,
        "total_reward_btc": 454.46120723,
        "total_subsidy_btc": 450,
        "total_transactions": 609372,
        "avg_fees_per_block_btc": 0.03098061,
        "avg_reward_per_block_btc": 3.15598061
    },
    "meta": {
        "timestamp": "2026-06-12T19:35:55.836Z",
        "request_id": "bf148722-3181-41ee-a2de-bf80c62b7273"
    },
    "status": "ok",
    "message": "Reward stats retrieved successfully",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Service metadata

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hashrate-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "difficulty, halving and meta take no parameters. hashrate takes period (1m/3m/6m/1y/2y/3y/all, default 1y) and limit (1-365, default 30). rewards takes blocks (1-1000, default 144). Hashrate is in EH/s, difficulty in raw and trillions, rewards in BTC (from satoshis), times in UTC ISO-8601. A short ~60-second protective cache fronts the upstream.",
        "source": "mempool.space public API, keyless, live",
        "service": "hashrate-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/halving": "Countdown to the next block-subsidy halving (height, subsidy, blocks/days left).",
            "GET /v1/rewards": "Block-reward economics over a window — subsidy, fees, fee share (blocks).",
            "GET /v1/hashrate": "Network hashrate in EH/s, now and as a timeseries (period, limit).",
            "GET /v1/difficulty": "Current difficulty + the next-adjustment countdown (progress, projected change, blocks left)."
        },
        "description": "Bitcoin's network-security and mining-economics layer, live and keyless: hashrate, mining difficulty, the difficulty-adjustment countdown, the halving countdown and per-window block-reward economics, from mempool.space. The difficulty endpoint gives the current difficulty and the live adjustment countdown (epoch progress, projected change, blocks to retarget); hashrate gives the network hashrate in EH/s plus a historical timeseries; halving counts down to 
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/hashrate-api
OpenAPI spec: https://www.oanor.com/api/hashrate-api/openapi.json
