Documentation
¶
Index ¶
- Constants
- type Activity
- type ActivitySortBy
- type ActivityType
- type Client
- func (c *Client) GetActivity(ctx context.Context, params *GetActivityParams) ([]Activity, error)
- func (c *Client) GetClosedPositions(ctx context.Context, params *GetClosedPositionsParams) ([]ClosedPosition, error)
- func (c *Client) GetHolders(ctx context.Context, params *GetHoldersParams) ([]MarketHolders, error)
- func (c *Client) GetLiveVolume(ctx context.Context, params *GetLiveVolumeParams) ([]LiveVolume, error)
- func (c *Client) GetOpenInterest(ctx context.Context, params *GetOpenInterestParams) ([]OpenInterest, error)
- func (c *Client) GetPositions(ctx context.Context, params *GetPositionsParams) ([]Position, error)
- func (c *Client) GetPositionsValue(ctx context.Context, params *GetValueParams) ([]UserValue, error)
- func (c *Client) GetTradedMarketsCount(ctx context.Context, params *GetTradedMarketsCountParams) (*TradedMarketsCount, error)
- func (c *Client) GetTrades(ctx context.Context, params *GetTradesParams) ([]Trade, error)
- func (c *Client) HealthCheck(ctx context.Context) (*HealthResponse, error)
- type ClosedPosition
- type ClosedPositionSortBy
- type ErrorResponse
- type FilterType
- type GetActivityParams
- type GetClosedPositionsParams
- type GetHoldersParams
- type GetLiveVolumeParams
- type GetOpenInterestParams
- type GetPositionsParams
- type GetTradedMarketsCountParams
- type GetTradesParams
- type GetValueParams
- type HealthResponse
- type Holder
- type LiveVolume
- type LiveVolumeMarket
- type MarketHolders
- type OpenInterest
- type Position
- type SortBy
- type SortDirection
- type Trade
- type TradeSide
- type TradedMarketsCount
- type UserValue
Constants ¶
const Endpoint = "https://data-api.polymarket.com"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct {
ProxyWallet string `json:"proxyWallet"` // User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Timestamp int64 `json:"timestamp"`
ConditionId string `json:"conditionId"` // 0x-prefixed 64-hex string. Example: "0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917"
Type ActivityType `json:"type"` // Available options: TRADE, SPLIT, MERGE, REDEEM, REWARD, CONVERSION
Size decimal.Decimal `json:"size"`
UsdcSize decimal.Decimal `json:"usdcSize"`
TransactionHash string `json:"transactionHash"`
Price decimal.Decimal `json:"price"`
Asset string `json:"asset"`
Side TradeSide `json:"side"` // Available options: BUY, SELL
OutcomeIndex int `json:"outcomeIndex"`
Title string `json:"title"`
Slug string `json:"slug"`
Icon string `json:"icon"`
EventSlug string `json:"eventSlug"`
Outcome string `json:"outcome"`
Name string `json:"name"`
Pseudonym string `json:"pseudonym"`
Bio string `json:"bio"`
ProfileImage string `json:"profileImage"`
ProfileImageOptimized string `json:"profileImageOptimized"`
}
Activity represents a user's on-chain activity
type ActivitySortBy ¶
type ActivitySortBy string
ActivitySortBy represents the sort field for activities
const ( ActivitySortByTimestamp ActivitySortBy = "TIMESTAMP" ActivitySortByTokens ActivitySortBy = "TOKENS" ActivitySortByCash ActivitySortBy = "CASH" )
type ActivityType ¶
type ActivityType string
ActivityType represents the type of activity
const ( ActivityTypeTrade ActivityType = "TRADE" ActivityTypeSplit ActivityType = "SPLIT" ActivityTypeMerge ActivityType = "MERGE" ActivityTypeRedeem ActivityType = "REDEEM" ActivityTypeReward ActivityType = "REWARD" ActivityTypeConversion ActivityType = "CONVERSION" )
type Client ¶ added in v0.1.0
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetActivity ¶ added in v0.1.0
GetActivity retrieves on-chain activity for a user
func (*Client) GetClosedPositions ¶ added in v0.1.0
func (c *Client) GetClosedPositions(ctx context.Context, params *GetClosedPositionsParams) ([]ClosedPosition, error)
GetClosedPositions fetches closed positions for a user
func (*Client) GetHolders ¶ added in v0.1.0
func (c *Client) GetHolders(ctx context.Context, params *GetHoldersParams) ([]MarketHolders, error)
GetHolders retrieves top holders for markets
func (*Client) GetLiveVolume ¶ added in v0.1.0
func (c *Client) GetLiveVolume(ctx context.Context, params *GetLiveVolumeParams) ([]LiveVolume, error)
GetLiveVolume retrieves the live volume for an event
func (*Client) GetOpenInterest ¶ added in v0.1.0
func (c *Client) GetOpenInterest(ctx context.Context, params *GetOpenInterestParams) ([]OpenInterest, error)
GetOpenInterest retrieves the open interest for markets
func (*Client) GetPositions ¶ added in v0.1.0
GetPositions retrieves current positions for a user
func (*Client) GetPositionsValue ¶ added in v0.1.0
func (c *Client) GetPositionsValue(ctx context.Context, params *GetValueParams) ([]UserValue, error)
GetPositionsValue retrieves the total value of a user's positions
func (*Client) GetTradedMarketsCount ¶ added in v0.1.0
func (c *Client) GetTradedMarketsCount(ctx context.Context, params *GetTradedMarketsCountParams) (*TradedMarketsCount, error)
GetTradedMarketsCount retrieves the total number of markets a user has traded
func (*Client) HealthCheck ¶ added in v0.1.0
func (c *Client) HealthCheck(ctx context.Context) (*HealthResponse, error)
HealthCheck performs a health check on the Polymarket Data API Returns "OK" if the API is healthy
type ClosedPosition ¶
type ClosedPosition struct {
ProxyWallet string `json:"proxyWallet"` // User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Asset string `json:"asset"`
ConditionId string `json:"conditionId"` // 0x-prefixed 64-hex string. Example: "0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917"
AvgPrice decimal.Decimal `json:"avgPrice"`
TotalBought decimal.Decimal `json:"totalBought"`
RealizedPnl decimal.Decimal `json:"realizedPnl"`
CurPrice decimal.Decimal `json:"curPrice"`
Title string `json:"title"`
Slug string `json:"slug"`
Icon string `json:"icon"`
EventSlug string `json:"eventSlug"`
Outcome string `json:"outcome"`
OutcomeIndex int `json:"outcomeIndex"`
OppositeOutcome string `json:"oppositeOutcome"`
OppositeAsset string `json:"oppositeAsset"`
EndDate string `json:"endDate"`
}
ClosedPosition represents a closed position for a user
type ClosedPositionSortBy ¶
type ClosedPositionSortBy string
ClosedPositionSortBy represents the sort field for closed positions
const ( ClosedPositionSortByRealizedPnl ClosedPositionSortBy = "REALIZEDPNL" ClosedPositionSortByTitle ClosedPositionSortBy = "TITLE" ClosedPositionSortByPrice ClosedPositionSortBy = "PRICE" ClosedPositionSortByAvgPrice ClosedPositionSortBy = "AVGPRICE" )
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents a standard error response from the API
type FilterType ¶
type FilterType string
FilterType represents the filter type for trades
const ( FilterTypeCash FilterType = "CASH" FilterTypeTokens FilterType = "TOKENS" )
type GetActivityParams ¶
type GetActivityParams struct {
Limit int // Optional: Default 100, required range: 0 <= x <= 500. 0 means not set.
Offset int // Optional: Default 0, required range: 0 <= x <= 10000. 0 means not set.
User string // Required: User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Market []string // Optional: Comma-separated list of condition IDs (0x-prefixed 64-hex string). Mutually exclusive with EventId.
EventId []int // Optional: Comma-separated list of event IDs. Mutually exclusive with Market.
Type []ActivityType // Optional: Activity type filters
Start int64 // Optional: Start timestamp, required range: x >= 0. 0 means not set.
End int64 // Optional: End timestamp, required range: x >= 0. 0 means not set.
SortBy ActivitySortBy // Optional: Default TIMESTAMP. Available options: TIMESTAMP, TOKENS, CASH
SortDirection SortDirection // Optional: Default DESC. Available options: ASC, DESC
Side TradeSide // Optional: Available options: BUY, SELL
}
GetActivityParams represents parameters for getting user activity
type GetClosedPositionsParams ¶
type GetClosedPositionsParams struct {
User string // Required: The address of the user. Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Market []string // Optional: The conditionId of the market (0x-prefixed 64-hex string). Cannot be used with EventId.
Title string // Optional: Filter by market title. Maximum length: 100
EventId []int // Optional: The event id. Returns positions for all markets for those event ids. Cannot be used with Market.
Limit int // Optional: Default 50, required range: 0 <= x <= 500. 0 means not set.
Offset int // Optional: Default 0, required range: 0 <= x <= 10000. 0 means not set.
SortBy ClosedPositionSortBy // Optional: Default REALIZEDPNL. Available options: REALIZEDPNL, TITLE, PRICE, AVGPRICE
SortDirection SortDirection // Optional: Default DESC. Available options: ASC, DESC
}
GetClosedPositionsParams represents parameters for getting closed positions
type GetHoldersParams ¶
type GetHoldersParams struct {
Limit int // Optional: Default 100, required range: 0 <= x <= 500. 0 means not set.
Market []string // Required: Comma-separated list of condition IDs (0x-prefixed 64-hex string)
MinBalance int // Optional: Default 1, required range: 0 <= x <= 999999. 0 means not set.
}
GetHoldersParams represents parameters for getting top holders
type GetLiveVolumeParams ¶
type GetLiveVolumeParams struct {
Id int // Required: Event ID, required range: x >= 1
}
GetLiveVolumeParams represents parameters for getting live volume
type GetOpenInterestParams ¶
type GetOpenInterestParams struct {
Market []string // Optional: List of market condition IDs (0x-prefixed 64-hex string)
}
GetOpenInterestParams represents parameters for getting open interest
type GetPositionsParams ¶
type GetPositionsParams struct {
User string // Required: User address. Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Market []string // Optional: Comma-separated list of condition IDs. 0x-prefixed 64-hex string. Mutually exclusive with EventId.
EventId []int // Optional: Comma-separated list of event IDs. Mutually exclusive with Market.
SizeThreshold *decimal.Decimal // Optional: Default 1, required range: x >= 0
Redeemable *bool // Optional: Default false
Mergeable *bool // Optional: Default false
Limit int // Optional: Default 100, required range: 0 <= x <= 500. 0 means not set.
Offset int // Optional: Default 0, required range: 0 <= x <= 10000. 0 means not set.
SortBy SortBy // Optional: Default TOKENS. Available options: CURRENT, INITIAL, TOKENS, CASHPNL, PERCENTPNL, TITLE, RESOLVING, PRICE, AVGPRICE
SortDirection SortDirection // Optional: Default DESC. Available options: ASC, DESC
Title string // Optional: Maximum length: 100
}
GetPositionsParams represents parameters for getting user positions
type GetTradedMarketsCountParams ¶
type GetTradedMarketsCountParams struct {
User string // Required: User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
}
GetTradedMarketsCountParams represents parameters for getting traded markets count
type GetTradesParams ¶
type GetTradesParams struct {
Limit int // Optional: Default 100, required range: 0 <= x <= 10000. 0 means not set.
Offset int // Optional: Default 0, required range: 0 <= x <= 10000. 0 means not set.
TakerOnly *bool // Optional: Default true
FilterType FilterType // Optional: Must be provided together with FilterAmount. Available options: CASH, TOKENS
FilterAmount *decimal.Decimal // Optional: Must be provided together with FilterType. Required range: x >= 0
Market []string // Optional: Comma-separated list of condition IDs (0x-prefixed 64-hex string). Mutually exclusive with EventId.
EventId []int // Optional: Comma-separated list of event IDs. Mutually exclusive with Market.
User string // Optional: User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Side TradeSide // Optional: Available options: BUY, SELL
}
GetTradesParams represents parameters for getting trades
type GetValueParams ¶
type GetValueParams struct {
User string // Required: User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Market []string // Optional: List of condition IDs (0x-prefixed 64-hex string)
}
GetValueParams represents parameters for getting user's total position value
type HealthResponse ¶
type HealthResponse struct {
Data string `json:"data"`
}
HealthResponse represents the response from the health check endpoint
type Holder ¶
type Holder struct {
ProxyWallet string `json:"proxyWallet"` // User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Bio string `json:"bio"` // User bio
Asset string `json:"asset"` // Asset address
Pseudonym string `json:"pseudonym"` // User pseudonym
Amount decimal.Decimal `json:"amount"` // Amount held
DisplayUsernamePublic bool `json:"displayUsernamePublic"` // Whether username is public
OutcomeIndex int `json:"outcomeIndex"` // Outcome index
Name string `json:"name"` // User name
ProfileImage string `json:"profileImage"` // Profile image URL
ProfileImageOptimized string `json:"profileImageOptimized"` // Optimized profile image URL
}
Holder represents a holder of a market token
type LiveVolume ¶
type LiveVolume struct {
Total decimal.Decimal `json:"total"` // Total volume
Markets []LiveVolumeMarket `json:"markets"` // List of market volumes
}
LiveVolume represents the live volume for an event
type LiveVolumeMarket ¶
type LiveVolumeMarket struct {
Market string `json:"market"` // 0x-prefixed 64-hex string. Example: "0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917"
Value decimal.Decimal `json:"value"` // Volume value
}
LiveVolumeMarket represents the volume for a specific market
type MarketHolders ¶
type MarketHolders struct {
Token string `json:"token"` // Token address
Holders []Holder `json:"holders"` // List of holders
}
MarketHolders represents holders for a specific market token
type OpenInterest ¶
type OpenInterest struct {
Market string `json:"market"` // 0x-prefixed 64-hex string. Example: "0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917"
Value decimal.Decimal `json:"value"` // Open interest value
}
OpenInterest represents the open interest for a market
type Position ¶
type Position struct {
ProxyWallet string `json:"proxyWallet"`
Asset string `json:"asset"`
ConditionId string `json:"conditionId"`
Size decimal.Decimal `json:"size"`
AvgPrice decimal.Decimal `json:"avgPrice"`
InitialValue decimal.Decimal `json:"initialValue"`
CurrentValue decimal.Decimal `json:"currentValue"`
CashPnl decimal.Decimal `json:"cashPnl"`
PercentPnl decimal.Decimal `json:"percentPnl"`
TotalBought decimal.Decimal `json:"totalBought"`
RealizedPnl decimal.Decimal `json:"realizedPnl"`
PercentRealizedPnl decimal.Decimal `json:"percentRealizedPnl"`
CurPrice decimal.Decimal `json:"curPrice"`
Redeemable bool `json:"redeemable"`
Mergeable bool `json:"mergeable"`
Title string `json:"title"`
Slug string `json:"slug"`
Icon string `json:"icon"`
EventSlug string `json:"eventSlug"`
Outcome string `json:"outcome"`
OutcomeIndex int `json:"outcomeIndex"`
OppositeOutcome string `json:"oppositeOutcome"`
OppositeAsset string `json:"oppositeAsset"`
EndDate string `json:"endDate"`
NegativeRisk bool `json:"negativeRisk"`
}
Position represents a user's position in a market
type SortBy ¶
type SortBy string
SortBy represents the sort field for positions
const ( SortByCurrent SortBy = "CURRENT" SortByInitial SortBy = "INITIAL" SortByTokens SortBy = "TOKENS" SortByCashPnl SortBy = "CASHPNL" SortByPercentPnl SortBy = "PERCENTPNL" SortByTitle SortBy = "TITLE" SortByResolving SortBy = "RESOLVING" SortByPrice SortBy = "PRICE" SortByAvgPrice SortBy = "AVGPRICE" )
type SortDirection ¶
type SortDirection string
SortDirection represents the sort direction
const ( SortDirectionAsc SortDirection = "ASC" SortDirectionDesc SortDirection = "DESC" )
type Trade ¶
type Trade struct {
ProxyWallet string `json:"proxyWallet"` // User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Side TradeSide `json:"side"` // Available options: BUY, SELL
Asset string `json:"asset"`
ConditionId string `json:"conditionId"` // 0x-prefixed 64-hex string. Example: "0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917"
Size decimal.Decimal `json:"size"`
Price decimal.Decimal `json:"price"`
Timestamp int64 `json:"timestamp"`
Title string `json:"title"`
Slug string `json:"slug"`
Icon string `json:"icon"`
EventSlug string `json:"eventSlug"`
Outcome string `json:"outcome"`
OutcomeIndex int `json:"outcomeIndex"`
Name string `json:"name"`
Pseudonym string `json:"pseudonym"`
Bio string `json:"bio"`
ProfileImage string `json:"profileImage"`
ProfileImageOptimized string `json:"profileImageOptimized"`
TransactionHash string `json:"transactionHash"`
}
Trade represents a trade record
type TradedMarketsCount ¶
type TradedMarketsCount struct {
User string `json:"user"` // User Profile Address (0x-prefixed, 40 hex chars). Example: "0x56687bf447db6ffa42ffe2204a05edaa20f55839"
Traded int `json:"traded"` // Total number of markets traded
}
TradedMarketsCount represents the total number of markets a user has traded
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
market_liquidity_analyzer
command
|
|
|
price_momentum_analyzer
command
|
|
|
sentiment_reversal_detector
command
|
|
|
smart_money_tracker
command
|
|
|
whale_watcher
command
|