HashrateIndex Curtailment Bitcoin Mining API
HashrateIndex Curtailment Bitcoin Mining API

Energy Curtailment Strike Price API

When should you hash and when should you curtail? The Hashrate Index Bitcoin Mining Curtailment API has the answers.

Guzman Pintos
Guzman Pintos

Hashrate, the commodity that securitizes the Bitcoin network, is wholly backed by energy. For most industrial-scale miners, choosing whether or not to consume energy to mine BTC or to sell this energy back to producers can be a make-or-break decision for maximizing profit.

With the increased adoption of renewables in our grid systems, energy pricing has become incredibly complex and volatile. Bitcoin miners are helping our electrical grid systems by providing infinite demand below a certain economic threshold.

This curtailment threshold is dynamic, and it fluctuates with every Bitcoin price movement, with each surfeit/deficit in transaction fee revenue, and with each difficulty adjustment. Therefore, understanding this threshold is of the utmost importance for running a maximally efficient mining operation.

Hashrate Index's Bitcoin Mining Curtailment API delivers a strike price that will help you decide when it would be more profitable to hash vs. when it would be more profitable to power down.

Hashrate Index Bitcoin Mining Curtailment Code Snippets

Below are code snippets for querying the Hashrate Index Bitcoin Mining Curtailment API in Curl and Python.

To input a different efficiency average for your fleet, please replace the default efficiency (29.5 J/TH) to your desired efficiency average.

Hashrate Index Bitcoin Mining Curtailment API (Curl Command)

curl 'https://api.hashrateindex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'x-hi-api-key: API_KEY' \
  --data-raw '{"query":"query {\n  getCurtailmentStrikePrice(efficiency: \"EFFICIENCY\")\n}\n","variables":null}'

Hashrate Index Bitcoin Mining Curtailment API (Python Command)

import json
import requests
from typing import Dict, Any

API_HOST = "https://api.hashrateindex.com/graphql"
API_KEY = "API_KEY" # replace with your APIKEY

# ASICs efficiency used to compute the breakeven curtailment price per mW  
EFFICIENCY = 29.5 # replace with desired efficiency

# Perform requests against HashrateIndex API
def request(API_HOST: str, API_KEY: str, query: str, params: Dict[str, Any] = None):

    headers = {
        'Content-Type': 'application/json',
        'x-hi-api-key': f"{API_KEY}",
    }

    s = requests.Session()
    s.headers = headers

    response = s.request('POST',
                         API_HOST,
                         data=json.dumps({
                            'query': query,
                            'variables': params
                        }).encode('utf-8'))

    if response.status_code == 200:
        return response.json()
    elif response.content:
        raise Exception(
            str(response.status_code) + ": " + str(response.reason) + ": " +
            str(response.content.decode()))
    else:
        raise Exception(str(response.status_code) + ": " + str(response.reason))

# Build the GraphQL Query for the request
def get_curtailment_strike_price(efficiency: float):

    query = """query getCurtailmentStrikePrice ($efficiency: BigFloat!) {
                    getCurtailmentStrikePrice (efficiency: $efficiency) 
                }
    """
    
    params = {'efficiency': efficiency}
    
    return request(API_HOST, API_KEY, query, params)['data']['getCurtailmentStrikePrice']

# Execute request
resp = get_curtailment_strike_price(EFFICIENCY)
print(resp)

Please feel free to request an API Key (or send any questions our way) via [email protected]

Happy Hashing!

Luxor News