polybrainz_polymarket 1.2.1
polybrainz_polymarket: ^1.2.1 copied to clipboard
A comprehensive Dart wrapper for the Polymarket API including Gamma, CLOB, Data APIs and WebSocket streams.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.2.1 - 2026-01-18 #
Changed #
- Updated repository URL to
https://github.com/mayankjanmejay/PolybrainZ_Polymarket/
1.2.0 - 2026-01-18 #
Added #
New Enums
OutcomeType- Binary outcome types (yes,no) with helper methodsoppositegetter to get the opposite outcomeisYes,isNoboolean getterstryFromJson()for safe parsing
OrderStatus- Order lifecycle states (live,matched,filled,cancelled,pending,delayed)isActive,isTerminal,isCancellableboolean getters
GameStatus- Sports game states (scheduled,inProgress,halftime,ended,postponed,cancelled,suspended)isLive,isFinished,isUpcoming,isInterruptedboolean getters
Type-Safe Enum Getters on Models
Added enum parsing getters to all models with string fields that have fixed values:
CLOB Models:
Order-sideEnum,typeEnum,statusEnum,outcomeEnumTrade-sideEnum,statusEnum,outcomeEnumMakerOrder-outcomeEnumClobToken-outcomeEnum
Data Models:
TradeRecord-sideEnum,outcomeEnumActivity-outcomeEnum(already hadactivityType,sideEnum)Position-outcomeEnum,oppositeOutcomeEnumClosedPosition-outcomeEnum
Gamma Models:
Event-categoryEnum,sortByEnum,gameStatusEnum
WebSocket Models:
OrderWsMessage-sideEnum,typeEnum,outcomeEnumTradeWsMessage-sideEnum,statusEnum,outcomeEnum
Helper Methods on Models
- Added
toLegacyMap()to all model classes for simplified Map output - Added
yesPriceandnoPricegetters toMarketclass
1.1.0 - 2026-01-18 #
Added #
Category Enums
MarketCategory- Main categories (politics, sports, crypto, popCulture, business, science, etc.)PoliticsSubcategory- US elections, international, policy, supreme court, etc.SportsSubcategory- NFL, NBA, MLB, NHL, soccer leagues, UFC, Olympics, etc.CryptoSubcategory- Bitcoin, Ethereum, DeFi, NFTs, exchanges, etc.PopCultureSubcategory- Movies, TV, music, celebrities, awards, streaming, etc.BusinessSubcategory- Tech companies, stocks, Fed, economy, M&A, etc.ScienceSubcategory- AI, space, climate, biotech, medicine, etc.
CategoryDetector Utility
CategoryDetector.detectFromEvent()- Detect category from an EventCategoryDetector.detectFromMarket()- Detect category from a MarketCategoryDetector.detectFromTags()- Detect category from Tag listCategoryDetector.detectFromTagSlugs()- Detect category from slug stringsCategoryDetector.groupEventsByCategory()- Group events by detected categoryCategoryDetector.groupMarketsByCategory()- Group markets by detected categoryCategoryDetector.getSubcategoriesFor()- Get subcategory enum values for a category- Extension methods on
List<Event>andList<Market>for convenience
New Endpoints
GammaLeaderboardEndpoint- Get trader rankings via Gamma APIgetTopByProfit()- Top traders by profitgetTopByVolume()- Top traders by volumegetTopByMarketsTraded()- Top traders by markets tradedgetLeaderboard()- Custom ordering
EventsEndpoint Enhancements
- Added
hotparameter for trending events - Added
tagSlugparameter for category filtering getHotEvents()- Get trending/hot eventsgetFeaturedEvents()- Get featured eventsgetByTagSlug()- Get events by category sluggetEndingSoon()- Get events ending within a time window
MarketsEndpoint Enhancements
- Added
tagSlugparameter for category filtering getTopByVolume()- Top markets by total volumegetTopByVolume24hr()- Top markets by 24-hour volumegetTopByLiquidity()- Top markets by liquiditygetByTagSlug()- Get markets by category sluggetEndingSoon()- Get markets ending within a time window
1.0.0 - 2026-01-16 #
Added #
Core Infrastructure
ApiClient- HTTP client with automatic retry, rate limiting, and error handlingWebSocketClient- Base WebSocket client with auto-reconnect and heartbeatPolymarketExceptionhierarchy for typed error handlingResult<T, E>sealed class for functional error handling- Constants for all API URLs and configuration
Gamma API (Market Discovery)
GammaClient- Full client for Gamma APIEventsEndpoint- List, get by ID/slug, filter eventsMarketsEndpoint- List, get by ID/slug/conditionId, filter marketsTagsEndpoint- List tags, get related tagsSeriesEndpoint- List and get seriesCommentsEndpoint- List comments, get by userProfilesEndpoint- Get user profilesSearchEndpoint- Search events, tags, profilesSportsEndpoint- List teams, get sports metadata
CLOB API (Order Book & Trading)
ClobClient- Full client for CLOB APIClobMarketsEndpoint- CLOB-specific market dataOrderbookEndpoint- Get order books for tokensPricingEndpoint- Get prices, midpoints, spreads, price historyOrdersEndpoint- Post, get, cancel orders (L2 auth)ClobTradesEndpoint- Get trade history
Data API (Analytics)
DataClient- Full client for Data APIPositionsEndpoint- Get open/closed positionsDataTradesEndpoint- Get user/market trade historyActivityEndpoint- Get on-chain activityHoldersEndpoint- Get token/market holdersValueEndpoint- Get portfolio valueLeaderboardEndpoint- Get leaderboard rankings
WebSocket Clients
ClobWebSocket- Real-time order book, prices, user ordersRtdsWebSocket- Real-time crypto prices, comments- Auto-reconnect with exponential backoff
- Heartbeat/ping-pong support
- Typed message streams
Authentication
ApiCredentials- Model for API key, secret, passphraseL1Auth- EIP-712 signing for API key creation (placeholder)L2Auth- HMAC-SHA256 signing for trading operationsAuthService- Authentication orchestration
Models (25+ classes)
- Gamma: Event, Market, Tag, Category, Profile, Comment, Series, Team, SearchResult
- CLOB: ClobMarket, ClobToken, ClobRewards, OrderBook, OrderSummary, Order, OrderResponse, Trade, SimplifiedMarket
- Data: Position, ClosedPosition, TradeRecord, Activity, Holder, HoldingsValue, LeaderboardEntry
- WebSocket: WsMessage, BookMessage, PriceChangeMessage, LastTradePriceMessage, TradeWsMessage, OrderWsMessage, CryptoPriceMessage, CommentMessage
Enums (15 types)
- OrderSide, OrderType, OrderActionType, TradeStatus
- SortBy, SortDirection, FilterType
- ActivityType, ParentEntityType
- LeaderboardWindow, LeaderboardType
- WsEventType, WsChannel, RtdsTopic
- SignatureType
Notes #
- L1 authentication (EIP-712 signing) requires a proper Ethereum library like
web3dartfor production use - All models use
json_serializablefor JSON serialization - All models extend
Equatablefor value equality