Documentation
¶
Overview ¶
Package gamma provides a read-only client for the Polymarket Gamma market-data API.
Overview ¶
The Gamma API exposes market and event metadata, full-text search, tag relationships, sports data, public profiles, and user comments. All endpoints are public (no auth required).
Usage ¶
client := gamma.New(gamma.Config{}) // defaults to gamma-api.polymarket.com
// Search markets, events, profiles
var results gamma.SearchResults
client.Search(ctx, "election", &results)
// Get events and markets
events, _ := client.GetEvents(ctx, gamma.EventFilterParams{Active: truePtr})
markets, _ := client.GetMarkets(ctx, gamma.MarketFilterParams{Slug: "..."})
// Tags and related content
tags, _ := client.GetTags(ctx)
related, _ := client.GetRelatedTags(ctx, 12, gamma.RelatedTagParams{})
// Public profiles and comments
profile := gamma.PublicProfile{Address: "0x..."}
client.GetPublicProfile(ctx, &profile)
comments, _ := client.GetComments(ctx, gamma.CommentFilterParams{})
Default host: https://gamma-api.polymarket.com
Index ¶
- Constants
- type Client
- func (c *Client) GetComment(ctx context.Context, id int) ([]Comment, error)
- func (c *Client) GetComments(ctx context.Context, params CommentFilterParams) ([]Comment, error)
- func (c *Client) GetCommentsByUserAddress(ctx context.Context, address string) ([]Comment, error)
- func (c *Client) GetEvent(ctx context.Context, out *Event) error
- func (c *Client) GetEventBySlug(ctx context.Context, out *Event) error
- func (c *Client) GetEvents(ctx context.Context, params EventFilterParams) ([]Event, error)
- func (c *Client) GetMarket(ctx context.Context, out *Market) error
- func (c *Client) GetMarketBySlug(ctx context.Context, out *Market) error
- func (c *Client) GetMarkets(ctx context.Context, params MarketFilterParams) ([]Market, error)
- func (c *Client) GetPublicProfile(ctx context.Context, out *PublicProfile) error
- func (c *Client) GetRelatedTagRelationships(ctx context.Context, id int, params RelatedTagParams) ([]TagRelationship, error)
- func (c *Client) GetRelatedTagRelationshipsBySlug(ctx context.Context, slug string, params RelatedTagParams) ([]TagRelationship, error)
- func (c *Client) GetRelatedTags(ctx context.Context, id int, params RelatedTagParams) ([]Tag, error)
- func (c *Client) GetRelatedTagsBySlug(ctx context.Context, slug string, params RelatedTagParams) ([]Tag, error)
- func (c *Client) GetSeries(ctx context.Context, out *Series) error
- func (c *Client) GetSports(ctx context.Context) ([]SportsMetadata, error)
- func (c *Client) GetTag(ctx context.Context, out *Tag) error
- func (c *Client) GetTagBySlug(ctx context.Context, out *Tag) error
- func (c *Client) GetTags(ctx context.Context) ([]Tag, error)
- func (c *Client) GetTeams(ctx context.Context) ([]Team, error)
- func (c *Client) GetValidSportsMarketTypes(ctx context.Context, out *SportsMarketTypesResponse) error
- func (c *Client) Host() string
- func (c *Client) ListSeries(ctx context.Context, params SeriesFilterParams) ([]Series, error)
- func (c *Client) PublicSearch(ctx context.Context, query string, out *SearchResults) error
- func (c *Client) Search(ctx context.Context, query string, out *SearchResults) error
- type Comment
- type CommentFilterParams
- type Config
- type Event
- type EventFilterParams
- type Market
- type MarketFilterParams
- type PublicProfile
- type RelatedTagParams
- type Reward
- type SearchResults
- type Series
- type SeriesFilterParams
- type SportsMarketTypesResponse
- type SportsMetadata
- type Tag
- type TagRelationship
- type Team
Constants ¶
const DefaultHost = "https://gamma-api.polymarket.com"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetComment ¶
GetComment returns comments for a comment ID.
func (*Client) GetComments ¶
GetComments returns comments matching params.
func (*Client) GetCommentsByUserAddress ¶
GetCommentsByUserAddress returns comments for a user wallet address.
func (*Client) GetEvent ¶
GetEvent writes an event into out using out.ID, or out.Slug when ID is empty.
func (*Client) GetEventBySlug ¶
GetEventBySlug writes an event by out.Slug into out.
func (*Client) GetMarket ¶
GetMarket writes a market into out using out.ID, or out.Slug when ID is empty.
func (*Client) GetMarketBySlug ¶
GetMarketBySlug writes a market by out.Slug into out.
func (*Client) GetMarkets ¶
GetMarkets returns markets matching params.
func (*Client) GetPublicProfile ¶
func (c *Client) GetPublicProfile(ctx context.Context, out *PublicProfile) error
GetPublicProfile writes a public profile by out.Address into out.
func (*Client) GetRelatedTagRelationships ¶
func (c *Client) GetRelatedTagRelationships(ctx context.Context, id int, params RelatedTagParams) ([]TagRelationship, error)
GetRelatedTagRelationships returns ranked related-tag relationships for a tag ID.
func (*Client) GetRelatedTagRelationshipsBySlug ¶
func (c *Client) GetRelatedTagRelationshipsBySlug(ctx context.Context, slug string, params RelatedTagParams) ([]TagRelationship, error)
GetRelatedTagRelationshipsBySlug returns ranked related-tag relationships for a tag slug.
func (*Client) GetRelatedTags ¶
func (c *Client) GetRelatedTags(ctx context.Context, id int, params RelatedTagParams) ([]Tag, error)
GetRelatedTags returns related Tag records for a tag ID.
func (*Client) GetRelatedTagsBySlug ¶
func (c *Client) GetRelatedTagsBySlug(ctx context.Context, slug string, params RelatedTagParams) ([]Tag, error)
GetRelatedTagsBySlug returns related Tag records for a tag slug.
func (*Client) GetSports ¶
func (c *Client) GetSports(ctx context.Context) ([]SportsMetadata, error)
GetSports returns sports metadata.
func (*Client) GetTagBySlug ¶
GetTagBySlug writes a tag by out.Slug into out.
func (*Client) GetValidSportsMarketTypes ¶
func (c *Client) GetValidSportsMarketTypes(ctx context.Context, out *SportsMarketTypesResponse) error
GetValidSportsMarketTypes writes valid sports market types into out.
func (*Client) ListSeries ¶
ListSeries returns series matching params.
func (*Client) PublicSearch ¶
PublicSearch writes market, event, and public-profile matches into out.
type Comment ¶
type Comment struct {
ID pmtypes.Int `json:"id"`
Body string `json:"body"`
User string `json:"user"`
Address string `json:"address"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
Deleted bool `json:"deleted"`
ParentID pmtypes.Int `json:"parentId"`
RootID pmtypes.Int `json:"rootId"`
Depth pmtypes.Int `json:"depth"`
Market string `json:"market"`
EventID pmtypes.Int `json:"eventId"`
ReportCount pmtypes.Int `json:"reportCount"`
ReactionCount pmtypes.Int `json:"reactionCount"`
ProfileImage string `json:"profileImage"`
ProfileImageURL string `json:"profileImageUrl"`
Raw json.RawMessage `json:"-"`
}
Comment describes a Gamma comment.
func (*Comment) UnmarshalJSON ¶
type CommentFilterParams ¶
type CommentFilterParams struct {
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// Market filters by condition ID.
Market string
// EventID filters by event ID.
EventID int
// User filters by user wallet address.
User string
}
CommentFilterParams filters GET /comments requests.
type Event ¶
type Event struct {
ID pmtypes.Int `json:"id"`
Ticker string `json:"ticker"`
Slug string `json:"slug"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Description string `json:"description"`
ResolutionSource string `json:"resolutionSource"`
StartDate pmtypes.Time `json:"startDate"`
CreationDate pmtypes.Time `json:"creationDate"`
EndDate pmtypes.Time `json:"endDate"`
Image string `json:"image"`
Icon string `json:"icon"`
Active bool `json:"active"`
Closed bool `json:"closed"`
Archived bool `json:"archived"`
New bool `json:"new"`
Featured bool `json:"featured"`
Restricted bool `json:"restricted"`
Liquidity pmtypes.Float64 `json:"liquidity"`
Volume pmtypes.Float64 `json:"volume"`
OpenInterest pmtypes.Float64 `json:"openInterest"`
SortBy string `json:"sortBy"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
IsTemplate bool `json:"isTemplate"`
TemplateVariables string `json:"templateVariables"`
PublishedAt pmtypes.Time `json:"published_at"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
CreatedBy pmtypes.Int `json:"createdBy"`
UpdatedBy pmtypes.Int `json:"updatedBy"`
Competitive pmtypes.Float64 `json:"competitive"`
Volume24hr pmtypes.Float64 `json:"volume24hr"`
Volume1wk pmtypes.Float64 `json:"volume1wk"`
Volume1mo pmtypes.Float64 `json:"volume1mo"`
Volume1yr pmtypes.Float64 `json:"volume1yr"`
LiquidityClob pmtypes.Float64 `json:"liquidityClob"`
NegRisk bool `json:"negRisk"`
CommentCount pmtypes.Int `json:"commentCount"`
Markets []Market `json:"markets"`
Tags []Tag `json:"tags"`
Series []Series `json:"series"`
Raw json.RawMessage `json:"-"`
}
Event describes a Gamma event.
func (*Event) UnmarshalJSON ¶
type EventFilterParams ¶
type EventFilterParams = MarketFilterParams
EventFilterParams is an alias for MarketFilterParams.
type Market ¶
type Market struct {
ID pmtypes.Int `json:"id"`
Question string `json:"question"`
ConditionID string `json:"conditionId"`
Slug string `json:"slug"`
Description string `json:"description"`
ResolutionSource string `json:"resolutionSource"`
EndDate pmtypes.Time `json:"endDate"`
StartDate pmtypes.Time `json:"startDate"`
Image string `json:"image"`
Icon string `json:"icon"`
Active bool `json:"active"`
Closed bool `json:"closed"`
Archived bool `json:"archived"`
Resolved bool `json:"resolved"`
New bool `json:"new"`
Featured bool `json:"featured"`
Restricted bool `json:"restricted"`
Liquidity pmtypes.Float64 `json:"liquidity"`
Volume pmtypes.Float64 `json:"volume"`
OpenInterest pmtypes.Float64 `json:"openInterest"`
VolumeNum pmtypes.Float64 `json:"volumeNum"`
LiquidityNum pmtypes.Float64 `json:"liquidityNum"`
EndDateISO pmtypes.Time `json:"endDateIso"`
StartDateISO pmtypes.Time `json:"startDateIso"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
CreationDate pmtypes.Time `json:"creationDate"`
PublishedAt pmtypes.Time `json:"published_at"`
CreatedBy pmtypes.Int `json:"createdBy"`
UpdatedBy pmtypes.Int `json:"updatedBy"`
Ready bool `json:"ready"`
Funded bool `json:"funded"`
AcceptingOrders bool `json:"acceptingOrders"`
AcceptingOrderTimestamp pmtypes.Time `json:"acceptingOrderTimestamp"`
EnableOrderBook bool `json:"enableOrderBook"`
MinimumOrderSize pmtypes.Float64 `json:"minimumOrderSize"`
MinimumTickSize pmtypes.Float64 `json:"minimumTickSize"`
QuestionID pmtypes.String `json:"questionID"`
FPmm string `json:"fpmm"`
MakerBaseFee pmtypes.Float64 `json:"makerBaseFee"`
TakerBaseFee pmtypes.Float64 `json:"takerBaseFee"`
NotificationsEnabled bool `json:"notificationsEnabled"`
NegRisk bool `json:"negRisk"`
NegRiskMarketID pmtypes.String `json:"negRiskMarketID"`
NegRiskRequestID pmtypes.String `json:"negRiskRequestID"`
Competitive pmtypes.Float64 `json:"competitive"`
RewardsMinSize pmtypes.Float64 `json:"rewardsMinSize"`
RewardsMaxSpread pmtypes.Float64 `json:"rewardsMaxSpread"`
Spread pmtypes.Float64 `json:"spread"`
LastTradePrice pmtypes.Float64 `json:"lastTradePrice"`
BestBid pmtypes.Float64 `json:"bestBid"`
BestAsk pmtypes.Float64 `json:"bestAsk"`
OneDayPriceChange pmtypes.Float64 `json:"oneDayPriceChange"`
OneHourPriceChange pmtypes.Float64 `json:"oneHourPriceChange"`
OneWeekPriceChange pmtypes.Float64 `json:"oneWeekPriceChange"`
OneMonthPriceChange pmtypes.Float64 `json:"oneMonthPriceChange"`
OneYearPriceChange pmtypes.Float64 `json:"oneYearPriceChange"`
Outcomes pmtypes.StringSlice `json:"outcomes"`
OutcomePrices pmtypes.Float64Slice `json:"outcomePrices"`
ClobTokenIDs pmtypes.StringSlice `json:"clobTokenIds"`
Tags []Tag `json:"tags"`
Events []Event `json:"events"`
Rewards []Reward `json:"rewards"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
SortBy string `json:"sortBy"`
IsTemplate bool `json:"isTemplate"`
TemplateVariables string `json:"templateVariables"`
MarketType string `json:"marketType"`
GroupItemTitle string `json:"groupItemTitle"`
GroupItemThreshold pmtypes.String `json:"groupItemThreshold"`
OrderPriceMinTickSize pmtypes.Float64 `json:"orderPriceMinTickSize"`
OrderMinSize pmtypes.Float64 `json:"orderMinSize"`
Volume24hr pmtypes.Float64 `json:"volume24hr"`
Volume1wk pmtypes.Float64 `json:"volume1wk"`
Volume1mo pmtypes.Float64 `json:"volume1mo"`
Volume1yr pmtypes.Float64 `json:"volume1yr"`
LiquidityClob pmtypes.Float64 `json:"liquidityClob"`
VolumeClob pmtypes.Float64 `json:"volumeClob"`
Raw json.RawMessage `json:"-"`
}
Market describes a Gamma market.
func (*Market) UnmarshalJSON ¶
type MarketFilterParams ¶
type MarketFilterParams struct {
// Active filters by active status.
Active *bool
// Closed filters by closed status.
Closed *bool
// Archived filters by archived status.
Archived *bool
// Resolved filters by resolution status.
Resolved *bool
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// Order sets the sort field.
Order string
// Ascending sets the sort direction.
Ascending *bool
// TagID filters by tag ID.
TagID int
// EventID filters by event ID.
EventID int
// Slug filters by market slug.
Slug string
// NegativeRisk filters by neg-risk status.
NegativeRisk *bool
// AcceptingOrders filters by order book status.
AcceptingOrders *bool
// ClobTokenIDs filters by conditional token IDs.
ClobTokenIDs []string
// ConditionIDs filters by condition IDs.
ConditionIDs []string
// MarketMakerAddress filters by FPMM contract address.
MarketMakerAddress []string
}
MarketFilterParams filters GET /markets requests.
type PublicProfile ¶
type PublicProfile struct {
Address string `json:"address"`
Name string `json:"name"`
Username string `json:"username"`
Pseudonym string `json:"pseudonym"`
Bio string `json:"bio"`
ProfileImage string `json:"profileImage"`
ProfileImageOptimized string `json:"profileImageOptimized"`
DisplayUsernamePublic bool `json:"displayUsernamePublic"`
ProxyWallet string `json:"proxyWallet"`
Wallet string `json:"wallet"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
VolumeTraded pmtypes.Float64 `json:"volumeTraded"`
ProfitLoss pmtypes.Float64 `json:"profitLoss"`
PositionsValue pmtypes.Float64 `json:"positionsValue"`
Verified bool `json:"verified"`
VerifiedBadge bool `json:"verifiedBadge"`
XUsername string `json:"xUsername"`
Raw json.RawMessage `json:"-"`
}
PublicProfile describes a public user profile.
func (*PublicProfile) UnmarshalJSON ¶
func (p *PublicProfile) UnmarshalJSON(data []byte) error
type RelatedTagParams ¶
type RelatedTagParams struct {
// OmitEmpty removes tags with no related items.
OmitEmpty *bool
// Status filters by tag status.
Status string
}
RelatedTagParams filters GET /tags/:id/related-tags requests.
type Reward ¶
type Reward struct {
ID pmtypes.Int `json:"id"`
AssetAddress string `json:"assetAddress"`
StartDate pmtypes.Time `json:"startDate"`
EndDate pmtypes.Time `json:"endDate"`
RatePerDay pmtypes.Float64 `json:"ratePerDay"`
TotalRewards pmtypes.Float64 `json:"totalRewards"`
Raw json.RawMessage `json:"-"`
}
Reward describes a Gamma market reward configuration.
type SearchResults ¶
type SearchResults struct {
Markets []Market `json:"markets"`
Events []Event `json:"events"`
Series []Series `json:"series"`
Tags []Tag `json:"tags"`
}
SearchResults contains public search matches.
type Series ¶
type Series struct {
ID pmtypes.Int `json:"id"`
Ticker string `json:"ticker"`
Slug string `json:"slug"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Description string `json:"description"`
Image string `json:"image"`
Icon string `json:"icon"`
Active bool `json:"active"`
Closed bool `json:"closed"`
Archived bool `json:"archived"`
Volume pmtypes.Float64 `json:"volume"`
Liquidity pmtypes.Float64 `json:"liquidity"`
StartDate pmtypes.Time `json:"startDate"`
EndDate pmtypes.Time `json:"endDate"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
Events []Event `json:"events"`
Tags []Tag `json:"tags"`
Raw json.RawMessage `json:"-"`
}
Series describes a Gamma series.
func (*Series) UnmarshalJSON ¶
type SeriesFilterParams ¶
type SeriesFilterParams struct {
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// Active filters by active status.
Active *bool
// Closed filters by closed status.
Closed *bool
// Archived filters by archived status.
Archived *bool
// Slug filters by series slug.
Slug string
// TagID filters by tag ID.
TagID int
// Ascending sets the sort direction.
Ascending *bool
// Order sets the sort field.
Order string
}
SeriesFilterParams filters GET /series requests.
type SportsMarketTypesResponse ¶
type SportsMarketTypesResponse struct {
// MarketTypes lists the valid market type identifiers.
MarketTypes []string `json:"marketTypes"`
}
SportsMarketTypesResponse contains valid sports market types.
type SportsMetadata ¶
type SportsMetadata struct {
ID pmtypes.Int `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Label string `json:"label"`
TagID pmtypes.Int `json:"tagId"`
CreatedAt pmtypes.Time `json:"createdAt"`
Image string `json:"image"`
}
SportsMetadata describes a sport.
type Tag ¶
type Tag struct {
ID pmtypes.Int `json:"id"`
Label string `json:"label"`
Slug string `json:"slug"`
ForceShow bool `json:"forceShow"`
PublishedAt pmtypes.Time `json:"publishedAt"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
Raw json.RawMessage `json:"-"`
}
Tag describes a Gamma tag.
func (*Tag) UnmarshalJSON ¶
type TagRelationship ¶
type TagRelationship struct {
ID pmtypes.Int `json:"id"`
TagID pmtypes.Int `json:"tagID"`
RelatedTagID pmtypes.Int `json:"relatedTagID"`
Rank pmtypes.Int `json:"rank"`
}
TagRelationship describes a ranked relationship between two tags.
type Team ¶
type Team struct {
ID pmtypes.Int `json:"id"`
Name string `json:"name"`
Sport string `json:"sport"`
Logo string `json:"logo"`
Abbreviation string `json:"abbreviation"`
Image string `json:"image"`
CreatedAt pmtypes.Time `json:"createdAt"`
UpdatedAt pmtypes.Time `json:"updatedAt"`
}
Team describes a sports team.