Developer API

Hashprice API
Free & Open

Real-time Bitcoin hashprice in USD and BTC per terahash per day. No API key, no signup, no rate limits. Use it in your dashboard, bot, or app.

✓ No key required  ⛏ Powered by dmnd.work

Endpoint

GET https://stratumv2.com/api/hashprice

Returns the current Bitcoin hashprice derived from live BTC price, network difficulty, and average block fees. Data is cached for 60 seconds. Sources: CoinGecko (primary), Coinbase (fallback), blockchain.info, mempool.space.

Response Fields

FieldTypeDescription
priceUSDfloatHashprice in USD per TH per day
priceBTCfloatHashprice in BTC per TH per day
pricePerPHfloatHashprice in USD per PH per day
btcPricefloatCurrent BTC/USD spot price
difficultyfloatCurrent network difficulty
avgFeesBTCfloatAverage block fees over last 6 blocks (BTC)
timestampstringISO 8601 timestamp of the response
sourcestring"stratumv2.com"
powered_bystring"dmnd.work — Stratum V2 Bitcoin Mining Pool"
docsstringURL to this page

Try It

Code Examples

JavaScript / Fetch

// Fetch current hashprice
const res  = await fetch('https://stratumv2.com/api/hashprice');
const data = await res.json();

console.log(`Hashprice: $${data.priceUSD.toFixed(6)}/TH/day`);
console.log(`Per PH:    $${data.pricePerPH.toFixed(4)}/PH/day`);
console.log(`BTC:       $${data.btcPrice.toLocaleString()}`);

Python

import requests

data = requests.get('https://stratumv2.com/api/hashprice').json()

print(f"Hashprice: ${data['priceUSD']:.6f}/TH/day")
print(f"Per PH:    ${data['pricePerPH']:.4f}/PH/day")
print(f"BTC:       ${data['btcPrice']:,.0f}")

cURL

curl https://stratumv2.com/api/hashprice

Example Response

{
  "priceUSD":    0.0297556299,
  "priceBTC":    0.0000004334,
  "pricePerPH":  29.7556,
  "btcPrice":    68653.00,
  "difficulty":  114494789739471,
  "avgFeesBTC":  0.000412,
  "timestamp":   "2026-03-14T12:00:00.000Z",
  "source":      "stratumv2.com",
  "powered_by":  "dmnd.work — Stratum V2 Bitcoin Mining Pool",
  "docs":        "https://stratumv2.com/api-docs"
}

How Hashprice is Calculated

Hashprice represents the expected daily revenue per terahash of mining power, before electricity costs.

// Standard hashprice formula
priceUSD = (86400 × (subsidy + avgFees) × btcPrice × 10¹²)
           ÷ (difficulty × 2³²)

// Where:
//   86400      = seconds per day
//   subsidy    = 3.125 BTC (post-halving block reward)
//   avgFees    = average fees per block over last 6 blocks
//   10¹²       = TH/s to H/s conversion
//   2³²        = difficulty target constant

Data refreshes every 60 seconds. BTC price sourced from CoinGecko with Coinbase fallback.

Attribution

This API is free to use. If you use it in a public project, a mention is appreciated — add a powered_by credit linking to stratumv2.com or dmnd.work.

<!-- Suggested attribution -->
Hashprice data by <a href="https://stratumv2.com">stratumv2.com</a>
Powered by <a href="https://dmnd.work">dmnd.work</a> — Stratum V2 Mining Pool