{"id":50308005,"url":"https://github.com/ivanzzeth/predict-go-clob-client","last_synced_at":"2026-05-28T18:01:39.541Z","repository":{"id":357523578,"uuid":"1132504407","full_name":"ivanzzeth/predict-go-clob-client","owner":"ivanzzeth","description":"Go SDK for predict.fun","archived":false,"fork":false,"pushed_at":"2026-05-13T05:05:07.000Z","size":240,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-13T07:10:38.519Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivanzzeth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-12T03:46:43.000Z","updated_at":"2026-05-13T05:05:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ivanzzeth/predict-go-clob-client","commit_stats":null,"previous_names":["ivanzzeth/predict-go-clob-client"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ivanzzeth/predict-go-clob-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanzzeth%2Fpredict-go-clob-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanzzeth%2Fpredict-go-clob-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanzzeth%2Fpredict-go-clob-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanzzeth%2Fpredict-go-clob-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanzzeth","download_url":"https://codeload.github.com/ivanzzeth/predict-go-clob-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanzzeth%2Fpredict-go-clob-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33619972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-28T18:01:39.421Z","updated_at":"2026-05-28T18:01:39.534Z","avatar_url":"https://github.com/ivanzzeth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Predict Go CLOB Client\n\nA Golang SDK for interacting with the Predict.fun platform API. This client provides a comprehensive interface for querying market data, managing orders, and performing chain operations on Predict.fun.\n\n## Features\n\n- 📊 **Market Data** - Query categories, markets, orderbooks, and statistics\n- 🔐 **Authentication** - EOA wallet authentication with JWT token support\n- 📝 **Order Management** - Create, cancel, and query orders\n- ⛓️ **Chain Operations** - Split, merge, and redeem positions with automatic neg-risk detection\n- 💰 **Balance \u0026 Positions** - Query user balances and positions\n- 🎯 **Type Safe** - Strongly typed API with clear interfaces\n- ⚡ **Caching** - Built-in market data caching with TTL support\n\n## Installation\n\n```bash\ngo get github.com/ivanzzeth/predict-go-clob-client\n```\n\n## Quick Start\n\n### Read-Only Client (API Key Required)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    \"github.com/ivanzzeth/predict-go-clob-client\"\n    \"github.com/ivanzzeth/predict-go-clob-client/constants\"\n)\n\nfunc main() {\n    // Create a read-only client with API key\n    client := predictclob.NewReadOnlyClient(constants.DefaultAPIHost, os.Getenv(\"PREDICT_API_KEY\"))\n\n    // Get categories\n    categories, err := client.GetCategories(nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"Found %d categories\\n\", len(categories.Data))\n\n    // Get markets\n    markets, err := client.GetMarkets(nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"Found %d markets\\n\", len(markets.Data))\n}\n```\n\n### Authenticated Client with Chain Operations\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"math/big\"\n    \"os\"\n\n    \"github.com/ethereum/go-ethereum/crypto\"\n    \"github.com/ivanzzeth/ethsig\"\n    \"github.com/ivanzzeth/predict-go-clob-client\"\n    \"github.com/ivanzzeth/predict-go-clob-client/constants\"\n    \"github.com/ivanzzeth/predict-go-clob-client/types\"\n    \"github.com/shopspring/decimal\"\n)\n\nfunc main() {\n    // Parse private key\n    privateKey, _ := crypto.HexToECDSA(os.Getenv(\"WALLET_PRIVATE_KEY\"))\n    signer := ethsig.NewEthPrivateKeySigner(privateKey)\n\n    // Create client with signer and RPC URL for chain operations\n    client, err := predictclob.NewClient(\n        predictclob.WithAPIHost(constants.DefaultAPIHost),\n        predictclob.WithAPIKey(os.Getenv(\"PREDICT_API_KEY\")),\n        predictclob.WithEOATradingSigner(signer),\n        predictclob.WithChainID(big.NewInt(56)), // BNB Mainnet\n        predictclob.WithRPCURL(os.Getenv(\"RPC_URL\")),\n    )\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Enable trading (approve tokens)\n    ctx := context.Background()\n    txHashes, err := client.EnableTrading(ctx)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"Enabled trading: %d transactions\\n\", len(txHashes))\n\n    // Split collateral into outcome tokens\n    marketID := types.MustMarketIDFromString(\"1910\")\n    amount := decimal.NewFromFloat(0.1)\n    txHash, err := client.Split(ctx, marketID, amount)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Printf(\"Split transaction: %s\\n\", txHash.Hex())\n}\n```\n\n## Examples\n\nThis SDK includes comprehensive examples for all major features. All examples use environment variables for configuration and load them from `.env` file in the project root.\n\n### Authentication\n\n- **[Authenticate](./examples/auth/authenticate/main.go)** - Authenticate with EOA wallet and get JWT token\n\n### Market Operations\n\n- **[List Markets](./examples/market/list/main.go)** - List all markets with pagination\n- **[Get Market Detail](./examples/market/detail/main.go)** - Get detailed information about a specific market\n- **[Get Categories](./examples/market/categories/main.go)** - List all market categories\n- **[Get Category](./examples/market/category/main.go)** - Get detailed information about a specific category\n- **[Find Open Markets](./examples/market/find-open/main.go)** - Find OPEN markets by querying OPEN categories\n- **[Get Orderbook](./examples/market/orderbook/main.go)** - Get orderbook for a market\n- **[Get Market Stats](./examples/market/stats/main.go)** - Get market statistics\n- **[Get Last Sale](./examples/market/last-sale/main.go)** - Get last sale information for a market\n\n### Order Operations\n\n- **[Place Order](./examples/order/place/main.go)** - Place a new order (BUY or SELL)\n- **[Cancel Orders](./examples/order/cancel/main.go)** - Cancel one or more orders\n- **[List Orders](./examples/order/list/main.go)** - List user's orders with filtering\n- **[Get Order by Hash](./examples/order/get-by-hash/main.go)** - Get order details by transaction hash\n- **[Get Matches](./examples/order/matches/main.go)** - Get order matches/trades\n\n### User Operations\n\n- **[Get Account](./examples/user/account/main.go)** - Get user account information\n- **[Get Positions](./examples/user/positions/main.go)** - Get user's positions (holdings)\n- **[Get Balance](./examples/user/balance/main.go)** - Get user's collateral balance\n- **[Get Activity](./examples/user/activity/main.go)** - Get user's trading activity\n\n### Chain Operations\n\n- **[Enable Trading](./examples/chain/enable-trading/main.go)** - Approve tokens for trading (required before split/merge/redeem)\n- **[Split](./examples/chain/split/main.go)** - Split collateral into outcome tokens\n- **[Merge](./examples/chain/merge/main.go)** - Merge outcome tokens back into collateral\n- **[Redeem](./examples/chain/redeem/main.go)** - Redeem positions for resolved markets\n\n## Environment Variables\n\nAll examples use environment variables loaded from `.env` file. Required variables:\n\n```bash\n# API Configuration\nPREDICT_API_KEY=your_api_key_here\n\n# Wallet Configuration (for authenticated operations)\nWALLET_PRIVATE_KEY=your_private_key_hex_here\n\n# RPC Configuration (for chain operations)\nRPC_URL=https://bnb-mainnet.g.alchemy.com/v2/your_key\n\n# Market/Order Configuration (example-specific)\nMARKET_ID=1910\nAMOUNT=0.1\nAMOUNTS=100000000000000000,100000000000000000  # For neg-risk redeem (comma-separated wei amounts)\n```\n\n## Running Examples\n\n```bash\n# Set environment variables\nexport PREDICT_API_KEY=your_api_key\nexport WALLET_PRIVATE_KEY=your_private_key\nexport RPC_URL=your_rpc_url\n\n# Or use .env file\ncp .env.example .env\n# Edit .env with your credentials\n\n# Run examples\ngo run ./examples/market/list/main.go\ngo run ./examples/chain/split/main.go MARKET_ID=1910 AMOUNT=0.1\ngo run ./examples/chain/redeem/main.go MARKET_ID=1757\n```\n\n## Key Features\n\n### Automatic Neg-Risk Detection\n\nThe SDK automatically detects neg-risk markets and uses the appropriate contract methods:\n\n```go\n// Automatically uses SplitNegRisk if market.IsNegRisk is true\ntxHash, err := client.Split(ctx, marketID, amount)\n\n// Automatically uses MergeNegRisk if market.IsNegRisk is true\ntxHash, err := client.Merge(ctx, marketID, amount)\n\n// Automatically uses RedeemNegRisk if market.IsNegRisk is true\ntxHash, err := client.Redeem(ctx, marketID, amounts)\n```\n\n### Market Data Caching\n\nEnable caching to reduce API calls for chain operations:\n\n```go\nclient, err := predictclob.NewClient(\n    predictclob.WithCacheTTL(5 * time.Minute), // Cache for 5 minutes\n    // ... other options\n)\n\n// Use cache for chain operations (only needs conditionID, not real-time data)\nmarket, err := client.GetMarket(marketID, true) // useCache=true\n```\n\n### Type Safety\n\nAll financial amounts use `decimal.Decimal` for precision:\n\n```go\namount := decimal.NewFromFloat(0.1)\ntxHash, err := client.Split(ctx, marketID, amount)\n```\n\n## API Reference\n\nSee [docs/API.md](docs/API.md) for detailed API documentation.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanzzeth%2Fpredict-go-clob-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanzzeth%2Fpredict-go-clob-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanzzeth%2Fpredict-go-clob-client/lists"}