Infra-Index Logo

Infra-Index Platform

v1.0.0
Foundation Live App GitHub Founder CV

Quickstart & Code Recipes

Production-ready code examples for consuming real-time GPU pricing, historical charts, and news feeds.

Recipe 1. Fetching Lowest GPU Hourly Rental Rates (Python)

import urllib.request
import json

def get_cheapest_gpus(gpu_name="H100", limit=5):
    url = f"https://infraindex-platform.vercel.app/api/v1/data/list?menu_id=gpu&limit={{limit}}&sort=PRICE_ASC"
    req = urllib.request.Request(url, headers={{"User-Agent": "InfraIndex-SDK/1.0"}})
    
    with urllib.request.urlopen(req) as resp:
        payload = json.loads(resp.read().decode("utf-8"))
        items = payload.get("data", [])
        
        print(f"=== Lowest {{gpu_name}} Hourly Rates ===")
        for item in items:
            name = item.get("name")
            offers = item.get("offers", [])
            if offers:
                best_offer = min(offers, key=lambda x: x.get("price_per_hour", 9999))
                print(f"{{name:<20}} | ${{best_offer['price_per_hour']:.2f}}/hr | Provider: {{best_offer['provider']}}")

if __name__ == "__main__":
    get_cheapest_gpus("H100")

Recipe 2. React / TypeScript Query Hook (Next.js 16)

import { useQuery } from '@tanstack/react-query';

interface HardwareItem {
  id: string;
  name: string;
  vram_gb: number;
  offers: Array<{
    provider: string;
    price_per_hour: number;
    region?: string;
  }>;
}

export function useHardwareList(menuId: 'gpu' | 'cpu' | 'storage' | 'baremetal') {
  return useQuery({
    queryKey: ['hardware', menuId],
    queryFn: async () => {
      const res = await fetch(
        `https://infraindex-platform.vercel.app/api/v1/data/list?menu_id=${{menuId}}&limit=50&sort=PROVIDERS_DESC`
      );
      if (!res.ok) throw new Error(`HTTP error: ${{res.status}}`);
      const json = await res.json();
      return json.data || [];
    },
    staleTime: 60 * 1000, // 1 minute fresh
  });
}

Recipe 3. Real-Time Price Candlestick & Historical OHLC (cURL / Bash)

# Query 30-day historical daily candlestick for NVIDIA A100
curl -s -X GET "https://infraindex-platform.vercel.app/api/v1/data/chart?menu_id=candlestick&hw_typ=gpu&target_ids=A100&timeframe=30d" \
  -H "Accept: application/json" | jq .

# Expected Output Envelope:
# {
#   "menu_id": "candlestick",
#   "data": {
#     "A100": [
#       { "x": "2026-08-01T00:00:00Z", "y": [1.45, 1.60, 1.35, 1.40], "highProvider": "vast-ai" }
#     ]
#   }
# }

Recipe 4. Executing Scheduled Crawler Batch (PowerShell)

# Run Development Batch (Isolated to DEV DB & Redis DB 0 prefix infraindex:dev:)
.\run_dev_crawl.ps1

# Run Production Batch with Automatic Vercel Edge Cache Invalidation
.\run_prd_crawl.ps1