Go SDK for the Polymarket Gamma RESTful API.
All market data necessary for market resolution is available on-chain (ie ancillaryData in UMA 00 request), but Polymarket also provides a hosted service, Gamma, that indexes this data and provides additional market metadata (ie categorization, indexed volume, etc). This service is made available through a REST API. For public users, this resource read only and can be used to fetch useful information about markets for things like non-profit research projects, alternative trading interfaces, automated trading systems etc.
API Endpoint: https://gamma-api.polymarket.com
- Complete Go SDK for Polymarket Gamma API
- Type-safe API with comprehensive market data structures
- Support for Markets, Events, Series, Search, Sports, and Tags endpoints
- Real-world examples for trading opportunity discovery
Requires Go 1.24 or later.
go get github.com/ivanzzeth/polymarket-go-gamma-clientpackage main
import (
"context"
"fmt"
"log"
"net/http"
polymarketgamma "github.com/ivanzzeth/polymarket-go-gamma-client"
)
func main() {
client := polymarketgamma.NewClient(http.DefaultClient)
// Fetch markets
closed := false
params := &polymarketgamma.GetMarketsParams{
Limit: 10,
Closed: &closed,
}
markets, err := client.GetMarkets(context.Background(), params)
if err != nil {
log.Fatal(err)
}
for _, market := range markets {
fmt.Printf("%s: $%.2f (24h vol: $%.2f)\n",
market.Question, market.LastTradePrice, market.Volume24hr)
}
}GetMarkets()- List markets with filteringGetMarketByID()- Get single market by IDGetMarketBySlug()- Get single market by slug
GetEvents()- List events with filteringGetEventByID()- Get single event by IDGetEventBySlug()- Get single event by slug
GetSeries()- List series with filteringGetSeriesByID()- Get single series by ID
Search()- Search markets, events, and profiles
HealthCheck()- Check API health status
GetTeams()- List sports teams with filteringGetSportsMetadata()- Get sports metadata including images and resolution sources
GetTags()- List tags with filteringGetTagByID()- Get single tag by IDGetTagBySlug()- Get single tag by slugGetRelatedTagsByID()- Get related tags by tag IDGetRelatedTagsBySlug()- Get related tags by tag slugGetRelatedTagsDetailByID()- Get detailed tag information for related tags by IDGetRelatedTagsDetailBySlug()- Get detailed tag information for related tags by slug
This repository includes comprehensive examples demonstrating various trading opportunity detection strategies:
Find markets where the bid-ask spread is significantly larger than the minimum tick size.
- Identifies inefficient markets with wide spreads
- Great for market makers to capture spread profits
- Filters out false positives (closed markets)
cd examples/find-wide-spread-markets
go run main.goDiscover markets with high trading activity but insufficient liquidity.
- High volume indicates strong interest
- Low liquidity means wider spreads
- Excellent opportunity for liquidity providers
- Provides detailed market making analysis
cd examples/find-low-liquidity-high-volume
go run main.goFind recently launched markets with early mover advantages.
- Markets less than 7 days old
- Low competition from other market makers
- Wide spreads and early positioning opportunities
- Includes opportunity scoring system
cd examples/find-new-active-markets
go run main.goIdentify events where probabilities don't sum to 100%.
- Exploits pricing inefficiencies across related markets
- Detects both underpriced and overpriced scenarios
- Calculates expected returns and ROI
- Provides detailed execution strategies
cd examples/find-related-markets-arbitrage
go run main.goDiscover capital-efficient trading using Negative Risk markets.
- Reduced collateral requirements
- NegRisk-specific arbitrage strategies
- Capital efficiency analysis
- Detailed fee impact calculations
cd examples/find-negrisk-opportunities
go run main.goDetect markets with significant 24-hour price changes.
- Identifies potential mean reversion opportunities
- Detects momentum trading signals
- Compares short-term vs long-term trends
- Suggests trading strategies based on movement type
cd examples/find-rapid-price-movement
go run main.goFind markets approaching resolution where outcomes may be predictable.
- Markets closing within 48 hours
- Identifies potential mispricing near expiration
- Distinguishes automatically vs manually resolved markets
- Includes resolution risk assessment
cd examples/find-closing-soon-markets
go run main.goSee ANALYSIS.md for comprehensive documentation on:
- Market making strategies
- Arbitrage techniques
- Statistical analysis approaches
- Risk management considerations
- Implementation guides
Contains comprehensive market data including:
- Pricing (bid, ask, last trade, spread)
- Volume (24h, 1w, 1m, total)
- Liquidity (CLOB, AMM, total)
- Order book settings (tick size, min size, fees)
- Price changes (1h, 1d, 1w, 1m)
- Resolution information
- Metadata and categorization
Represents trading events with:
- Multiple markets
- Series information
- Tags and categories
- Volume and liquidity aggregates
- NegRisk configuration
Unified search across:
- Markets
- Events
- Tags
- Profiles
- Rate Limiting: Respect API rate limits
- Error Handling: Always check for errors
- Data Validation: Verify market status and data quality
- Risk Management: Use appropriate position sizing
- Fee Awareness: Consider maker/taker fees in strategies
This SDK and examples are for educational and research purposes only. Trading prediction markets involves substantial risk. Always:
- Conduct thorough research
- Understand market mechanics
- Never risk more than you can afford to lose
- Verify all information independently
- Comply with local regulations
Past opportunities do not guarantee future results.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.
- Polymarket Documentation
- Gamma API Documentation
- CLOB API Documentation (for actual trading)
For issues and questions:
- Open an issue on GitHub
- Check existing examples for reference
- Review ANALYSIS.md for strategy details