API Quickstart – Version 1.1
1. Introduction
Cette page offre un démarrage rapide pour utiliser l’API GHI v1.1. Tous les appels sont accessibles sans authentification dans l’édition Sandbox. Les éditions institutionnelles (API clés, données enrichies, SLA) seront annoncées prochainement.
Les exemples ci-dessous montrent comment interroger les endpoints snapshot, history et regions.
2. URL de base
https://globalhashcostindex.org/api/v1/ghi/
Tous les appels API utilisent ce préfixe.
3. Appels immédiats (cURL)
Snapshot (coût global + régional)
curl https://globalhashcostindex.org/api/v1/ghi/snapshot
Historique (global)
curl "https://globalhashcostindex.org/api/v1/ghi/history?region_id=global"
Liste des régions
curl https://globalhashcostindex.org/api/v1/ghi/regions
4. Exemple Python (requests)
import requests
BASE = "https://globalhashcostindex.org/api/v1/ghi"
r = requests.get(f"{BASE}/snapshot")
data = r.json()
print("Global avg cost:", data["global_avg_cost_usd"])
S’intègre dans n’importe quel pipeline Python, ETL, Airflow, backtests, etc.
5. Exemple JavaScript (fetch)
const url = "https://globalhashcostindex.org/api/v1/ghi/snapshot";
fetch(url)
.then(res => res.json())
.then(data => {
console.log("Global avg cost:", data.global_avg_cost_usd);
});
6. Exemple pour données historiques
curl "https://globalhashcostindex.org/api/v1/ghi/history?region_id=us"
Réponse typique :
{
"version": "1.1",
"timestamp_utc": "...",
"region_id": "us",
"points": [
{
"date": "2025-12-01",
"min_cost_usd": 41000,
"avg_cost_usd": 45000,
"max_cost_usd": 49500
}
]
}
API Quickstart – Version 1.1
1. Introduction
This page provides a fast onboarding guide for GHI API v1.1. All endpoints are publicly accessible in the Sandbox edition. Institutional editions (API keys, enriched datasets, SLA) will be announced soon.
2. Base URL
https://globalhashcostindex.org/api/v1/ghi/
3. Immediate calls (cURL)
Snapshot
curl https://globalhashcostindex.org/api/v1/ghi/snapshot
History
curl "https://globalhashcostindex.org/api/v1/ghi/history?region_id=global"
Regions
curl https://globalhashcostindex.org/api/v1/ghi/regions
4. Python example
import requests
BASE = "https://globalhashcostindex.org/api/v1/ghi"
data = requests.get(f"{BASE}/snapshot").json()
print("Global avg cost:", data["global_avg_cost_usd"])
5. JavaScript example
fetch("https://globalhashcostindex.org/api/v1/ghi/snapshot")
.then(res => res.json())
.then(data => console.log("Global avg cost:", data.global_avg_cost_usd));
6. History example
curl "https://globalhashcostindex.org/api/v1/ghi/history?region_id=us"
{
"version": "1.1",
"region_id": "us",
"points": [
{"date": "2025-12-01", "avg_cost_usd": 45000}
]
}