Documentation
¶
Overview ¶
Package data provides a read-only client for the Polymarket Data API.
Overview ¶
The Data API exposes aggregated market analytics — positions, trades, activity, open interest, leaderboard rankings, and accounting snapshots. No authentication required; all endpoints use AuthNone.
Usage ¶
client := data.New(data.Config{}) // defaults to data-api.polymarket.com
// User positions
positions, _ := client.GetPositions(ctx, data.PositionParams{User: "0x..."})
// Trades
trades, _ := client.GetTrades(ctx, data.TradeParams{User: "0x...", Limit: 100})
// Open interest
oi, _ := client.GetOpenInterest(ctx, []string{"market1", "market2"})
// Combo positions and lifecycle activity
comboPositions, _ := client.GetComboPositions(ctx, data.ComboPositionParams{User: "0x..."})
comboActivity, _ := client.GetComboActivity(ctx, data.ComboActivityParams{User: "0x..."})
// Download accounting snapshot (ZIP)
zipData, _ := client.DownloadAccountingSnapshot(ctx, "0x...")
Default host: https://data-api.polymarket.com
Index ¶
- Constants
- type Activity
- type ActivityParams
- type BuilderLeaderboardEntry
- type BuilderLeaderboardParams
- type BuilderVolume
- type BuilderVolumeParams
- type Client
- func (c *Client) DownloadAccountingSnapshot(ctx context.Context, user string) ([]byte, error)
- func (c *Client) GetActivity(ctx context.Context, params ActivityParams) ([]Activity, error)
- func (c *Client) GetBuilderLeaderboard(ctx context.Context, params BuilderLeaderboardParams) ([]BuilderLeaderboardEntry, error)
- func (c *Client) GetBuilderVolume(ctx context.Context, params BuilderVolumeParams) ([]BuilderVolume, error)
- func (c *Client) GetClosedPositions(ctx context.Context, params ClosedPositionParams) ([]ClosedPosition, error)
- func (c *Client) GetComboActivity(ctx context.Context, params ComboActivityParams) (*ComboActivityPage, error)
- func (c *Client) GetComboPositions(ctx context.Context, params ComboPositionParams) (*ComboPositionPage, error)
- func (c *Client) GetHealth(ctx context.Context, out *Health) error
- func (c *Client) GetHolders(ctx context.Context, params HoldersParams) ([]Holder, error)
- func (c *Client) GetLeaderboard(ctx context.Context, params LeaderboardParams) ([]LeaderboardEntry, error)
- func (c *Client) GetLiveVolume(ctx context.Context, params LiveVolumeParams) ([]LiveVolume, error)
- func (c *Client) GetMarketPositions(ctx context.Context, params MarketPositionsParams) ([]MarketPositions, error)
- func (c *Client) GetOpenInterest(ctx context.Context, markets []string) ([]OpenInterest, error)
- func (c *Client) GetPositions(ctx context.Context, params PositionParams) ([]Position, error)
- func (c *Client) GetTraded(ctx context.Context, user string, out *Traded) error
- func (c *Client) GetTrades(ctx context.Context, params TradeParams) ([]Trade, error)
- func (c *Client) GetValue(ctx context.Context, user string, markets []string) ([]Value, error)
- func (c *Client) Host() string
- type ClosedPosition
- type ClosedPositionParams
- type ComboActivity
- type ComboActivityPage
- type ComboActivityParams
- type ComboActivityType
- type ComboPagination
- type ComboPosition
- type ComboPositionLeg
- type ComboPositionMarket
- type ComboPositionMarketEvent
- type ComboPositionPage
- type ComboPositionParams
- type ComboPositionSort
- type ComboPositionStatus
- type Config
- type Health
- type Holder
- type HoldersParams
- type LeaderboardEntry
- type LeaderboardParams
- type LiveVolume
- type LiveVolumeParams
- type MarketPosition
- type MarketPositions
- type MarketPositionsParams
- type OpenInterest
- type Position
- type PositionParams
- type Side
- type Trade
- type TradeParams
- type Traded
- type UnknownComboActivity
- type Value
Constants ¶
const DefaultHost = "https://data-api.polymarket.com"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct {
// ProxyWallet is the user's Polymarket proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// User is the wallet address.
User string `json:"user"`
// Name is the user's display name.
Name string `json:"name"`
// Pseudonym is the user's pseudonym.
Pseudonym string `json:"pseudonym"`
// Bio is the user's profile bio.
Bio string `json:"bio"`
// ProfileImage is the user's profile image URL.
ProfileImage string `json:"profileImage"`
// ProfileImageOptimized is the optimized profile image URL.
ProfileImageOptimized string `json:"profileImageOptimized"`
// Timestamp is when the activity occurred.
Timestamp pmtypes.Int64 `json:"timestamp"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"conditionId"`
// Type is the activity category.
Type string `json:"type"`
// Size is the token quantity.
Size pmtypes.Float64 `json:"size"`
// USDCSize is the USDC value.
USDCSize pmtypes.Float64 `json:"usdcSize"`
// TransactionHash is the on-chain transaction hash.
TransactionHash string `json:"transactionHash"`
// Price is the activity price.
Price pmtypes.Float64 `json:"price"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// Side is the trade direction.
Side string `json:"side"`
// Title is the market question text.
Title string `json:"title"`
// Slug is the URL-friendly market slug.
Slug string `json:"slug"`
// Icon is the market icon URL.
Icon string `json:"icon"`
// EventSlug is the parent event slug.
EventSlug string `json:"eventSlug"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
Activity describes a user activity event.
func (*Activity) UnmarshalJSON ¶
type ActivityParams ¶
type ActivityParams struct {
// User is the wallet address.
User string
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// Start is the start Unix timestamp.
Start int64
// End is the end Unix timestamp.
End int64
// SortBy sets the sort field.
SortBy string
// SortDirection sets the sort order.
SortDirection string
// Side filters by trade direction.
Side Side
// ActivityTypes filters by event categories.
ActivityTypes []string
}
ActivityParams filters GET /activity requests.
type BuilderLeaderboardEntry ¶
type BuilderLeaderboardEntry struct {
Builder string `json:"builder"`
Volume pmtypes.Float64 `json:"volume"`
Trades pmtypes.Int `json:"trades"`
Rank pmtypes.String `json:"rank"`
DisplayName string `json:"displayName"`
}
BuilderLeaderboardEntry describes an aggregated builder leaderboard row.
type BuilderLeaderboardParams ¶
type BuilderLeaderboardParams struct {
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
}
BuilderLeaderboardParams filters GET /v1/builders/leaderboard requests.
type BuilderVolume ¶
type BuilderVolume struct {
Date string `json:"date"`
Builder string `json:"builder"`
Volume pmtypes.Float64 `json:"volume"`
Trades pmtypes.Int `json:"trades"`
}
BuilderVolume describes a daily builder volume time-series row.
type BuilderVolumeParams ¶
type BuilderVolumeParams struct {
// Builder is the builder code.
Builder string
// Start is the start date.
Start string
// End is the end date.
End string
}
BuilderVolumeParams filters GET /v1/builders/volume requests.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DownloadAccountingSnapshot ¶
DownloadAccountingSnapshot downloads the accounting snapshot ZIP for a user.
func (*Client) GetActivity ¶
GetActivity returns user activity.
func (*Client) GetBuilderLeaderboard ¶
func (c *Client) GetBuilderLeaderboard(ctx context.Context, params BuilderLeaderboardParams) ([]BuilderLeaderboardEntry, error)
GetBuilderLeaderboard returns aggregated builder leaderboard rows.
func (*Client) GetBuilderVolume ¶
func (c *Client) GetBuilderVolume(ctx context.Context, params BuilderVolumeParams) ([]BuilderVolume, error)
GetBuilderVolume returns daily builder volume time-series rows.
func (*Client) GetClosedPositions ¶
func (c *Client) GetClosedPositions(ctx context.Context, params ClosedPositionParams) ([]ClosedPosition, error)
GetClosedPositions returns closed positions for a user.
func (*Client) GetComboActivity ¶ added in v1.3.2
func (c *Client) GetComboActivity(ctx context.Context, params ComboActivityParams) (*ComboActivityPage, error)
func (*Client) GetComboPositions ¶ added in v1.3.2
func (c *Client) GetComboPositions(ctx context.Context, params ComboPositionParams) (*ComboPositionPage, error)
func (*Client) GetHolders ¶
GetHolders returns top holders for markets.
func (*Client) GetLeaderboard ¶
func (c *Client) GetLeaderboard(ctx context.Context, params LeaderboardParams) ([]LeaderboardEntry, error)
GetLeaderboard returns trader leaderboard rankings.
func (*Client) GetLiveVolume ¶
func (c *Client) GetLiveVolume(ctx context.Context, params LiveVolumeParams) ([]LiveVolume, error)
GetLiveVolume returns live volume for an event or markets.
func (*Client) GetMarketPositions ¶
func (c *Client) GetMarketPositions(ctx context.Context, params MarketPositionsParams) ([]MarketPositions, error)
GetMarketPositions returns positions grouped by outcome token for a market.
func (*Client) GetOpenInterest ¶
GetOpenInterest returns open interest for markets.
func (*Client) GetPositions ¶
GetPositions returns current positions for a user.
type ClosedPosition ¶
type ClosedPosition struct {
// ProxyWallet is the user's Polymarket proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"conditionId"`
// AvgPrice is the average entry price.
AvgPrice pmtypes.Float64 `json:"avgPrice"`
// RealizedPNL is the profit/loss.
RealizedPNL pmtypes.Float64 `json:"realizedPnl"`
// PercentRealizedPNL is the profit/loss percentage.
PercentRealizedPNL pmtypes.Float64 `json:"percentRealizedPnl"`
// CurPrice is the current market price.
CurPrice pmtypes.Float64 `json:"curPrice"`
// Timestamp is when the position was closed.
Timestamp pmtypes.Int64 `json:"timestamp"`
// Title is the market question text.
Title string `json:"title"`
// Slug is the URL-friendly market slug.
Slug string `json:"slug"`
// Icon is the market icon URL.
Icon string `json:"icon"`
// EventSlug is the parent event slug.
EventSlug string `json:"eventSlug"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// OppositeOutcome is the complementary outcome label.
OppositeOutcome string `json:"oppositeOutcome"`
// OppositeAsset is the complementary token address.
OppositeAsset string `json:"oppositeAsset"`
// EndDate is the market resolution date.
EndDate string `json:"endDate"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
ClosedPosition describes a closed user position.
func (*ClosedPosition) UnmarshalJSON ¶
func (p *ClosedPosition) UnmarshalJSON(data []byte) error
type ClosedPositionParams ¶
type ClosedPositionParams = PositionParams
ClosedPositionParams is an alias for PositionParams.
type ComboActivity ¶ added in v1.3.2
type ComboActivity struct {
ID pmtypes.String `json:"id"`
Type ComboActivityType `json:"type"`
Wallet string `json:"user_address"`
ConditionID string `json:"combo_condition_id"`
ModuleID pmtypes.String `json:"module_id"`
Amount pmtypes.String `json:"amount_usdc"`
Timestamp pmtypes.Time `json:"timestamp"`
TransactionAt pmtypes.Time `json:"tx_dttm"`
TransactionHash string `json:"tx_hash"`
LogIndex pmtypes.Int `json:"log_index"`
BlockNumber pmtypes.String `json:"block_number"`
Legs []ComboPositionLeg `json:"legs"`
PositionID pmtypes.String `json:"combo_position_id"`
Payout pmtypes.String `json:"payout_usdc"`
Raw json.RawMessage `json:"-"`
}
func (ComboActivity) IsKnown ¶ added in v1.3.2
func (a ComboActivity) IsKnown() bool
func (ComboActivity) Unknown ¶ added in v1.3.2
func (a ComboActivity) Unknown() *UnknownComboActivity
func (*ComboActivity) UnmarshalJSON ¶ added in v1.3.2
func (a *ComboActivity) UnmarshalJSON(data []byte) error
type ComboActivityPage ¶ added in v1.3.2
type ComboActivityPage struct {
Activities []ComboActivity `json:"activity"`
Pagination ComboPagination `json:"pagination"`
}
type ComboActivityParams ¶ added in v1.3.2
type ComboActivityType ¶ added in v1.3.2
type ComboActivityType string
const ( ComboActivitySplit ComboActivityType = "SPLIT" ComboActivityMerge ComboActivityType = "MERGE" ComboActivityConvert ComboActivityType = "CONVERT" ComboActivityCompress ComboActivityType = "COMPRESS" ComboActivityWrap ComboActivityType = "WRAP" ComboActivityUnwrap ComboActivityType = "UNWRAP" ComboActivityRedeem ComboActivityType = "REDEEM" )
type ComboPagination ¶ added in v1.3.2
type ComboPosition ¶ added in v1.3.2
type ComboPosition struct {
ConditionID string `json:"combo_condition_id"`
PositionID pmtypes.String `json:"combo_position_id"`
Outcome string `json:"side"`
ModuleID pmtypes.String `json:"module_id"`
Wallet string `json:"user_address"`
EntryAveragePrice pmtypes.String `json:"entry_avg_price_usdc"`
EntryCost pmtypes.String `json:"entry_cost_usdc"`
RealizedPayout pmtypes.String `json:"realized_payout_usdc"`
TotalCost pmtypes.String `json:"total_cost_usdc"`
Status ComboPositionStatus `json:"status"`
Redeemable bool `json:"redeemable"`
FirstEntryAt pmtypes.Time `json:"first_entry_at"`
ResolvedAt pmtypes.Time `json:"resolved_at"`
UpdatedAt pmtypes.Time `json:"updated_at"`
LegsTotal pmtypes.Int `json:"legs_total"`
LegsResolved pmtypes.Int `json:"legs_resolved"`
LegsPending pmtypes.Int `json:"legs_pending"`
Legs []ComboPositionLeg `json:"legs"`
}
type ComboPositionLeg ¶ added in v1.3.2
type ComboPositionLeg struct {
Index pmtypes.Int `json:"leg_index"`
PositionID pmtypes.String `json:"leg_position_id"`
ConditionID string `json:"leg_condition_id"`
OutcomeIndex pmtypes.Int `json:"leg_outcome_index"`
OutcomeLabel string `json:"leg_outcome_label"`
Status ComboPositionStatus `json:"leg_status"`
ResolvedAt pmtypes.Time `json:"leg_resolved_at"`
CurrentPrice pmtypes.String `json:"leg_current_price"`
Market *ComboPositionMarket `json:"market"`
}
type ComboPositionMarket ¶ added in v1.3.2
type ComboPositionMarket struct {
MarketID pmtypes.String `json:"market_id"`
Slug string `json:"slug"`
Title string `json:"title"`
Outcome string `json:"outcome"`
ImageURL string `json:"image_url"`
IconURL string `json:"icon_url"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
Tags []string `json:"tags"`
EndDate pmtypes.Time `json:"end_date"`
Event *ComboPositionMarketEvent `json:"event"`
}
type ComboPositionMarketEvent ¶ added in v1.3.2
type ComboPositionPage ¶ added in v1.3.2
type ComboPositionPage struct {
Combos []ComboPosition `json:"combos"`
Pagination ComboPagination `json:"pagination"`
}
type ComboPositionParams ¶ added in v1.3.2
type ComboPositionParams struct {
User string
Status ComboPositionStatus
Sort ComboPositionSort
MarketIDs []string
Limit int
Offset int
Cursor string
UpdatedAfter int64
}
type ComboPositionSort ¶ added in v1.3.2
type ComboPositionSort string
const ( ComboPositionSortCurrentValueDesc ComboPositionSort = "current_value_desc" ComboPositionSortFirstEntryDesc ComboPositionSort = "first_entry_desc" ComboPositionSortEntryCostDesc ComboPositionSort = "entry_cost_desc" ComboPositionSortResolvedAtDesc ComboPositionSort = "resolved_at_desc" ComboPositionSortUpdatedAsc ComboPositionSort = "updated_asc" )
type ComboPositionStatus ¶ added in v1.3.2
type ComboPositionStatus string
const ( ComboPositionOpen ComboPositionStatus = "OPEN" ComboPositionPartial ComboPositionStatus = "PARTIAL" ComboPositionResolvedWin ComboPositionStatus = "RESOLVED_WIN" ComboPositionResolvedLoss ComboPositionStatus = "RESOLVED_LOSS" )
type Health ¶
type Health struct {
// Data is the health status string.
Data string `json:"data"`
}
Health is the Data API health response.
type Holder ¶
type Holder struct {
// ProxyWallet is the holder's proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// Name is the display name.
Name string `json:"name"`
// Pseudonym is the user's pseudonym.
Pseudonym string `json:"pseudonym"`
// Bio is the user's profile bio.
Bio string `json:"bio"`
// ProfileImage is the profile image URL.
ProfileImage string `json:"profileImage"`
// ProfileImageOptimized is the optimized profile image URL.
ProfileImageOptimized string `json:"profileImageOptimized"`
// DisplayUsernamePublic indicates whether the display username is public.
DisplayUsernamePublic bool `json:"displayUsernamePublic"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// Amount is the token balance.
Amount pmtypes.Float64 `json:"amount"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// Verified is true for verified accounts.
Verified bool `json:"verified"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
Holder describes a market holder.
func (*Holder) UnmarshalJSON ¶
type HoldersParams ¶
type HoldersParams struct {
// Markets filters by condition IDs.
Markets []string
// Limit sets the maximum results.
Limit int
// MinBalance filters by minimum token balance.
MinBalance int
}
HoldersParams filters GET /holders requests.
type LeaderboardEntry ¶
type LeaderboardEntry struct {
// Rank is the leaderboard rank.
Rank pmtypes.String `json:"rank"`
// ProxyWallet is the user's proxy wallet address.
ProxyWallet string `json:"proxyWallet"`
// UserName is the display username.
UserName string `json:"userName"`
// Vol is the leaderboard volume.
Vol pmtypes.Float64 `json:"vol"`
// PNL is the leaderboard profit and loss.
PNL pmtypes.Float64 `json:"pnl"`
// ProfileImage is the user's profile image URL.
ProfileImage string `json:"profileImage"`
// XUsername is the user's X username.
XUsername string `json:"xUsername"`
// VerifiedBadge indicates whether the user has a verified badge.
VerifiedBadge bool `json:"verifiedBadge"`
}
type LeaderboardParams ¶
type LeaderboardParams struct {
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// Category filters by leaderboard category.
Category string
// TimePeriod filters by time range.
TimePeriod string
// OrderBy sets the sort field.
OrderBy string
}
LeaderboardParams filters GET /v1/leaderboard requests.
type LiveVolume ¶
type LiveVolume struct {
// Market is the condition ID.
Market string `json:"market"`
// Volume is the total traded volume in USDC.
Volume pmtypes.Float64 `json:"volume"`
}
LiveVolume describes live volume for an event or market.
type LiveVolumeParams ¶
type LiveVolumeParams struct {
// Markets filters by condition IDs.
Markets []string
}
LiveVolumeParams filters GET /live-volume requests.
type MarketPosition ¶
type MarketPosition struct {
// ProxyWallet is the user's proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// Name is the display name.
Name string `json:"name"`
// ProfileImage is the profile image URL.
ProfileImage string `json:"profileImage"`
// Verified is true for verified accounts.
Verified bool `json:"verified"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"conditionId"`
// AvgPrice is the average entry price.
AvgPrice pmtypes.Float64 `json:"avgPrice"`
// Size is the position size.
Size pmtypes.Float64 `json:"size"`
// CurrPrice is the current market price.
CurrPrice pmtypes.Float64 `json:"currPrice"`
// CurrentValue is the current market value.
CurrentValue pmtypes.Float64 `json:"currentValue"`
// CashPNL is the realized profit/loss in USDC.
CashPNL pmtypes.Float64 `json:"cashPnl"`
// TotalBought is the total USDC spent.
TotalBought pmtypes.Float64 `json:"totalBought"`
// RealizedPNL is the realized profit/loss.
RealizedPNL pmtypes.Float64 `json:"realizedPnl"`
// TotalPNL is the total profit/loss.
TotalPNL pmtypes.Float64 `json:"totalPnl"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
MarketPosition describes a user's position in a market outcome token.
func (*MarketPosition) UnmarshalJSON ¶
func (p *MarketPosition) UnmarshalJSON(data []byte) error
type MarketPositions ¶
type MarketPositions struct {
// Token is the outcome token identifier.
Token string `json:"token"`
// Positions lists the user positions.
Positions []MarketPosition `json:"positions"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
MarketPositions groups user positions for a single outcome token.
func (*MarketPositions) UnmarshalJSON ¶
func (p *MarketPositions) UnmarshalJSON(data []byte) error
type MarketPositionsParams ¶
type MarketPositionsParams struct {
// Market is the condition ID.
Market string
// User is the wallet address.
User string
// Status filters by position status.
Status string
// SortBy sets the sort field.
SortBy string
// SortDirection sets the sort order.
SortDirection string
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
}
MarketPositionsParams filters GET /v1/market-positions requests.
type OpenInterest ¶
type OpenInterest struct {
// Market is the condition ID.
Market string `json:"market"`
// Value is the open interest in USDC.
Value pmtypes.Float64 `json:"value"`
}
OpenInterest describes market open interest.
type Position ¶
type Position struct {
// ProxyWallet is the user's Polymarket proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"conditionId"`
// Size is the current position size.
Size pmtypes.Float64 `json:"size"`
// AvgPrice is the average entry price.
AvgPrice pmtypes.Float64 `json:"avgPrice"`
// InitialValue is the position cost in USDC.
InitialValue pmtypes.Float64 `json:"initialValue"`
// CurrentValue is the current market value.
CurrentValue pmtypes.Float64 `json:"currentValue"`
// CashPNL is the realized profit/loss in USDC.
CashPNL pmtypes.Float64 `json:"cashPnl"`
// PercentPNL is the realized profit/loss percentage.
PercentPNL pmtypes.Float64 `json:"percentPnl"`
// TotalBought is the total USDC spent.
TotalBought pmtypes.Float64 `json:"totalBought"`
// RealizedPNL is the realized profit/loss from sales.
RealizedPNL pmtypes.Float64 `json:"realizedPnl"`
// PercentRealizedPNL is the realized profit/loss percentage.
PercentRealizedPNL pmtypes.Float64 `json:"percentRealizedPnl"`
// CurPrice is the current market price.
CurPrice pmtypes.Float64 `json:"curPrice"`
// Redeemable is true when the position can be redeemed.
Redeemable bool `json:"redeemable"`
// Mergeable is true when positions can be merged.
Mergeable bool `json:"mergeable"`
// Title is the market question text.
Title string `json:"title"`
// Slug is the URL-friendly market slug.
Slug string `json:"slug"`
// Icon is the market icon URL.
Icon string `json:"icon"`
// EventSlug is the parent event slug.
EventSlug string `json:"eventSlug"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// OppositeOutcome is the complementary outcome label.
OppositeOutcome string `json:"oppositeOutcome"`
// OppositeAsset is the complementary token address.
OppositeAsset string `json:"oppositeAsset"`
// EndDate is the market resolution date.
EndDate string `json:"endDate"`
// NegativeRisk is true for neg-risk markets.
NegativeRisk bool `json:"negativeRisk"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
Position describes a current user position.
func (*Position) UnmarshalJSON ¶
type PositionParams ¶
type PositionParams struct {
// User is the wallet address to query.
User string
// Markets filters by condition IDs.
Markets []string
// EventIDs filters by event IDs.
EventIDs []int
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// SortBy sets the sort field.
SortBy string
// SortDirection sets the sort order.
SortDirection string
// Title filters by market title.
Title string
// Redeemable filters by redeemable status.
Redeemable *bool
// Mergeable filters by mergeable status.
Mergeable *bool
// SizeThreshold filters by minimum position size.
SizeThreshold string
}
PositionParams filters GET /positions requests.
type Trade ¶
type Trade struct {
// ProxyWallet is the user's Polymarket proxy wallet.
ProxyWallet string `json:"proxyWallet"`
// User is the wallet address.
User string `json:"user"`
// Name is the user's display name.
Name string `json:"name"`
// Pseudonym is the user's pseudonym.
Pseudonym string `json:"pseudonym"`
// Bio is the user's profile bio.
Bio string `json:"bio"`
// ProfileImage is the user's profile image URL.
ProfileImage string `json:"profileImage"`
// ProfileImageOptimized is the optimized profile image URL.
ProfileImageOptimized string `json:"profileImageOptimized"`
// Side is the trade direction.
Side Side `json:"side"`
// Asset is the ERC-1155 token address.
Asset string `json:"asset"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"conditionId"`
// Size is the trade quantity.
Size pmtypes.Float64 `json:"size"`
// Price is the execution price.
Price pmtypes.Float64 `json:"price"`
// Timestamp is when the trade occurred.
Timestamp pmtypes.Int64 `json:"timestamp"`
// Title is the market question text.
Title string `json:"title"`
// Slug is the URL-friendly market slug.
Slug string `json:"slug"`
// Icon is the market icon URL.
Icon string `json:"icon"`
// EventSlug is the parent event slug.
EventSlug string `json:"eventSlug"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex pmtypes.Int `json:"outcomeIndex"`
// TransactionHash is the on-chain transaction hash.
TransactionHash string `json:"transactionHash"`
// Raw contains the unparsed JSON response.
Raw json.RawMessage `json:"-"`
}
Trade describes a Data API trade.
func (*Trade) UnmarshalJSON ¶
type TradeParams ¶
type TradeParams struct {
// User is the wallet address.
User string
// Markets filters by condition IDs.
Markets []string
// EventIDs filters by event IDs.
EventIDs []int
// Limit sets the maximum results.
Limit int
// Offset sets the start index.
Offset int
// TakerOnly filters to taker-side trades.
TakerOnly *bool
// Side filters by BUY or SELL.
Side Side
// FilterType selects an amount comparator such as CASH, TOKENS, or SHARES.
FilterType string
// FilterAmount is the comparator threshold amount.
FilterAmount string
}
TradeParams filters GET /trades requests.
type Traded ¶
type Traded struct {
// User is the wallet address.
User string `json:"user"`
// Traded is the number of unique markets traded.
Traded pmtypes.Int `json:"traded"`
}
Traded contains the total markets traded response.
type UnknownComboActivity ¶ added in v1.3.2
type UnknownComboActivity struct {
Type ComboActivityType
Raw json.RawMessage
}
UnknownComboActivity preserves a lifecycle event introduced by the server before this client has a typed representation for it.
type Value ¶
type Value struct {
// User is the wallet address.
User string `json:"user"`
// Market is the condition ID.
Market string `json:"market"`
// Value is the total portfolio value.
Value pmtypes.Float64 `json:"value"`
// Cash is the USDC balance.
Cash pmtypes.Float64 `json:"cash"`
// Tokens is the token position value.
Tokens pmtypes.Float64 `json:"tokens"`
}
Value describes user portfolio value for a market.