API Quickstart
1. Introduction
Cette page offre un démarrage rapide pour utiliser l’API GHI. Tous les appels sont accessibles sans authentification dans l’édition Sandbox. Les éditions institutionnelles (clés API, données enrichies, SLA) seront annoncées ultérieurement.
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
}
]
}
7. Endpoint /metadata
L’endpoint GET /v1/ghi/metadata renvoie des informations structurées
sur l’API et le moteur sandbox.
GET https://globalhashcostindex.org/api/v1/ghi/metadata
Exemple de réponse (simplifiée) :
{
"version": "1.1",
"timestamp_utc": "2025-12-10T09:30:00Z",
"engine_version": "0.4.3-sandbox",
"environment": "sandbox",
"api_current": "1.1",
"api_supported": ["1.0", "1.1"]
}
API Quickstart
1. Introduction
This page provides a fast onboarding guide for the GHI API. All endpoints are publicly accessible in the Sandbox edition. Institutional editions (API keys, enriched datasets, SLA) will be announced later.
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}
]
}
7. /metadata endpoint
The GET /v1/ghi/metadata endpoint returns structured information
about the API and the sandbox engine.
GET https://globalhashcostindex.org/api/v1/ghi/metadata
Example response (simplified):
{
"version": "1.1",
"timestamp_utc": "2025-12-10T09:30:00Z",
"engine_version": "0.4.3-sandbox",
"environment": "sandbox",
"api_current": "1.1",
"api_supported": ["1.0", "1.1"]
}