API Reference
KalshChain provides a read-only REST API (powered by Supabase) for fast access to market data.
Base URL
All API requests should be made to the following base URL:
text code
https://[YOUR_SUPABASE_URL]/rest/v1Authentication is required via the apiKey header.
Endpoints
GET /kalshchain_markets
Retrieves a list of all prediction markets, including title, reserves, and current prices.
bash code
curl -X GET 'https://[URL]/rest/v1/kalshchain_markets?select=*' \
-H 'apikey: YOUR_ANON_KEY' \
-H 'Authorization: Bearer YOUR_ANON_KEY'GET /kalshchain_markets?id=eq.{id}
Retrieves a single market by its unique ID.
bash code
curl -X GET 'https://[URL]/rest/v1/kalshchain_markets?id=eq.1' \
-H 'apikey: YOUR_ANON_KEY' \
-H 'Authorization: Bearer YOUR_ANON_KEY'GET /kalshchain_trades
Retrieves the history of all executed trades. Supports filtering by user_id and market_id.
bash code
curl -X GET 'https://[URL]/rest/v1/kalshchain_trades?user_id=eq.[pubkey]' \
-H 'apikey: YOUR_ANON_KEY' \
-H 'Authorization: Bearer YOUR_ANON_KEY'Realtime API
The Supabase Realtime API allows you to subscribe to database changes for instant updates on new trades and market price changes.
realtime.js
// Example of subscribing to new trade insertions
supabase
.channel('trades')
.on('postgres_changes', {
event: 'INSERT',
schema: 'public',
table: 'kalshchain_trades'
}, payload => {
console.log('New Trade:', payload.new)
})
.subscribe()