Why Batch APIs?
When you need data on 50 markets, making 50 separate API calls is slow and wasteful. A batch API lets you send all 50 requests in one call and get all 50 responses back at once.
Benefits of Batching
- Reduced latency: One round-trip instead of fifty
- Lower rate limit usage: One request instead of fifty against your quota
- Atomic responses: All data comes from the same point in time
- Connection efficiency: Reuses a single HTTP connection
Batch Endpoints in SimpleFunctions
POST /api/batch/markets— Get prices for multiple marketsPOST /api/batch/edges— Calculate edge for multiple thesis-market pairsPOST /api/batch/depth— Get orderbook snapshots for multiple markets
Usage Pattern
POST /api/batch/markets
{
"markets": [
"KXRECSSNBER-26",
"KXCPI-26MAR-T3.5",
"KXGDP-26Q2-T2.0"
]
}
Response returns data for all three markets in a single object.
CLI Batch Operations
The CLI uses batch APIs automatically. When you run sf scan or sf edges, it batches market queries behind the scenes for optimal performance. A scan that would take 30 seconds with individual requests completes in 2-3 seconds with batching.