### Install Predict SDK with npm Source: https://dev.predict.fun/doc-679306 Installs the Predict SDK and its peer dependency, ethers v6, using the npm package manager. ```bash npm install @predictdotfun/sdk ethers ``` -------------------------------- ### Install Predict SDK with Yarn Source: https://dev.predict.fun/doc-679306 Installs the Predict SDK and its peer dependency, ethers v6, using the Yarn package manager. ```bash yarn add @predictdotfun/sdk ethers ``` -------------------------------- ### GET /v1/orders/{hash} Source: https://dev.predict.fun/api-25326901 Retrieves the order information for a specific order using its hash. This endpoint allows users to get details of their own orders. ```APIDOC ## GET /v1/orders/{hash} ### Description Get the order information for one of your own orders by its hash. ### Method GET ### Endpoint /v1/orders/{hash} ### Parameters #### Path Parameters - **hash** (string) - Required - a string ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the order data. - **order** (object) - Detailed order information. - **hash** (string) - A non-empty string representing the order hash. - **salt** (string) - A non-empty string representing the order salt. - **maker** (string) - The maker's address. - **signer** (string) - The signer's address. - **taker** (string) - The taker's address. Must be '0x0000000000000000000000000000000000000000'. - **tokenId** (string) - A non-empty string representing the token ID. - **makerAmount** (string) - A non-empty string representing the maker's amount. - **takerAmount** (string) - A non-empty string representing the taker's amount. - **expiration** (number) - A Unix timestamp in seconds, must be in the future. - **nonce** (string) - A non-empty string representing the nonce. - **feeRateBps** (string) - A non-empty string representing the fee rate in basis points. - **side** (number) - The order side (0 or 1). - **signatureType** (number) - The signature type (0). - **signature** (string) - The order signature. - **id** (string) - A non-empty string representing the order ID. #### Response Example ```json { "success": true, "data": { "order": { "hash": "0xabc123...", "salt": "12345", "maker": "0xmaker...", "signer": "0xsigner...", "taker": "0x0000000000000000000000000000000000000000", "tokenId": "token123", "makerAmount": "100", "takerAmount": "200", "expiration": 1678886400, "nonce": "98765", "feeRateBps": "50", "side": 0, "signatureType": 0, "signature": "0xsignature..." }, "id": "orderId123" } } ``` ``` -------------------------------- ### Interface with Predict.fun Contracts using SDK Source: https://dev.predict.fun/doc-679306 Shows how to interface with Predict.fun's smart contracts using the SDK. It initializes an OrderBuilder with a signer and accesses contract instances, including their ABIs and types. The example retrieves the USDT balance of the signer's address. ```typescript import { OrderBuilder, ChainId } from "@predictdotfun/sdk"; import { Wallet } from "ethers"; // Create a wallet to interact with on-chain contracts const signer = new Wallet(process.env.WALLET_PRIVATE_KEY); // The main function initiates the OrderBuilder (only once per signer) // Then provides it as dependency to other functions async function main() { // Create a new instance of the OrderBuilder class. Note: This should only be done once per signer const orderBuilder = await OrderBuilder.make(ChainId.BnbMainnet, signer); await callContracts(orderBuilder); } async function callContracts(orderBuilder: OrderBuilder) { // If the signer is not provided within `OrderBuilder.make` the contracts won't be initiated if (!orderBuilder.contracts) { throw new Error("The signer was not provided during the OrderBuilder init."); } // You can now call contract functions (the actual contract instance is within `contract`) // The `codec` property contains the ethers Interface, useful to encode and decode data const balance = await orderBuilder.contracts["USDT"].contract.balanceOf(signer.address); } ``` -------------------------------- ### GET /v1/orders Source: https://dev.predict.fun/api-25326902 Retrieves a list of the user's orders. Supports filtering by 'first', 'after', and 'status'. ```APIDOC ## GET /v1/orders ### Description Get a list of your own orders. You can filter orders by providing query parameters. ### Method GET ### Endpoint /v1/orders ### Parameters #### Query Parameters - **first** (string) - Optional - Decoded into a number. - **after** (string) - Optional - Used for pagination. - **status** (string) - Optional - Filter by order status. Allowed values: OPEN, FILLED. ### Request Example ```json { "example": "GET /v1/orders?status=OPEN&after=somecursor" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **cursor** (string | null) - A cursor for next page of results. - **data** (array) - An array of order objects. - **order** (object) - **hash** (string) - A non-empty string representing the order hash. - **salt** (string) - A non-empty string representing the order salt. - **maker** (string) - The maker's address. - **signer** (string) - The signer's address. - **taker** (string) - The taker's address. Can be '0x0000000000000000000000000000000000000000'. - **tokenId** (string) - A non-empty string representing the token ID. - **makerAmount** (string) - A non-empty string representing the maker's amount. - **takerAmount** (string) - A non-empty string representing the taker's amount. - **expiration** (number) - A Unix timestamp in seconds, must be in the future. Can be a string that will be trimmed or an integer. - **nonce** (string) - A non-empty string representing the nonce. - **feeRateBps** (string) - A non-empty string representing the fee rate in basis points. - **side** (number) - The order side (0 or 1). #### Response Example ```json { "example": { "success": true, "cursor": "somecursor", "data": [ { "order": { "hash": "0x...", "salt": "123", "maker": "0x...", "signer": "0x...", "taker": "0x0000000000000000000000000000000000000000", "tokenId": "abc", "makerAmount": "100", "takerAmount": "200", "expiration": 1678886400, "nonce": "456", "feeRateBps": "30", "side": 0 } } ] } } ``` ``` -------------------------------- ### GET /v1/positions Source: https://dev.predict.fun/api-25326909 Retrieves data about your positions. Supports pagination and filtering. ```APIDOC ## GET /v1/positions ### Description Get data about your positions. ### Method GET ### Endpoint /v1/positions ### Parameters #### Query Parameters - **first** (string) - Optional - a string to be decoded into a number - **after** (string) - Optional - a string ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **success** (boolean) - a boolean - **cursor** (string) - a string, nullable - **data** (array) - array of position objects - **id** (string) - a string - **market** (object) - market details - **id** (number) - a number - **imageUrl** (string) - a non empty string - **title** (string) - a non empty string - **question** (string) - a non empty string - **description** (string) - a non empty string - **status** (string) - enum: REGISTERED, PRICE_PROPOSED, PRICE_DISPUTED, PAUSED, UNPAUSED, RESOLVED - **isNegRisk** (boolean) - a boolean - **isYieldBearing** (boolean) - a boolean - **feeRateBps** (number) - a number - **resolution** (object) - resolution details, nullable - **name** (string) - a string - **indexSet** (integer) - an integer - **onChainId** (string) - bigint string - **status** (string) - enum: WON, LOST, nullable - **oracleQuestionId** (string) - a string - **conditionId** (string) - a non empty string - **resolverAddress** (string) - a string - **outcomes** (any) - placeholder for outcomes structure #### Response Example ```json { "success": true, "cursor": "some-cursor-string", "data": [ { "id": "pos_123", "market": { "id": 456, "imageUrl": "http://example.com/image.jpg", "title": "Will BTC price exceed $50000 tomorrow?", "question": "Will BTC price exceed $50000 tomorrow?", "description": "This market resolves based on the price of Bitcoin.", "status": "RESOLVED", "isNegRisk": false, "isYieldBearing": true, "feeRateBps": 100, "resolution": { "name": "Yes", "indexSet": 1, "onChainId": "0xabcdef123456", "status": "WON" }, "oracleQuestionId": "oq_abc", "conditionId": "cond_xyz", "resolverAddress": "0x123...", "outcomes": [ "Yes", "No" ] } } ] } ``` ``` -------------------------------- ### GET /v1/categories/{slug} Source: https://dev.predict.fun/api-25326911 Retrieves detailed information about a specific category using its slug, including associated markets. ```APIDOC ## GET /v1/categories/{slug} ### Description Retrieves category information and its markets by slug. ### Method GET ### Endpoint /v1/categories/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - The unique slug of the category. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the category details and its markets. - **id** (number) - The unique identifier for the category. - **slug** (string) - The slug of the category. - **title** (string) - The title of the category. - **description** (string) - The description of the category. - **imageUrl** (string) - The URL of the category's image. - **isNegRisk** (boolean) - Flag indicating negative risk. - **isYieldBearing** (boolean) - Flag indicating if the category is yield-bearing. - **marketVariant** (string) - The variant of the market (e.g., DEFAULT, SPORTS_MATCH, CRYPTO_UP_DOWN). - **createdAt** (string) - The date and time when the category was created. - **markets** (array) - A list of markets associated with the category. - **id** (number) - The unique identifier for the market. - **imageUrl** (string) - The URL of the market's image. - **title** (string) - The title of the market. - **question** (string) - The question associated with the market. - **description** (string) - The description of the market. - **status** (string) - The status of the market (e.g., REGISTERED, RESOLVED). - **isNegRisk** (boolean) - Flag indicating negative risk for the market. - **isYieldBearing** (boolean) - Flag indicating if the market is yield-bearing. - **feeRateBps** (number) - The fee rate in basis points. - **resolution** (object) - Details about the market resolution. - **name** (string) - The name of the resolution. - **indexSet** (integer) - The index set for the resolution. - **onChainId** (string) - The on-chain ID for the resolution. - **status** (string) - The status of the resolution (WON or LOST). #### Response Example ```json { "success": true, "data": { "id": 1, "slug": "example-category", "title": "Example Category", "description": "This is an example category.", "imageUrl": "https://example.com/image.jpg", "isNegRisk": false, "isYieldBearing": false, "marketVariant": "DEFAULT", "createdAt": "2023-10-27T10:00:00Z", "markets": [ { "id": 101, "imageUrl": "https://example.com/market.jpg", "title": "Example Market", "question": "Will it rain tomorrow?", "description": "Market to predict rainfall.", "status": "RESOLVED", "isNegRisk": false, "isYieldBearing": false, "feeRateBps": 100, "resolution": { "name": "Rain", "indexSet": 1, "onChainId": "0x123abc", "status": "WON" } } ] } } ``` ``` -------------------------------- ### GET /v1/account Source: https://dev.predict.fun/api-25326917 Retrieves information for the currently connected user account. This endpoint is part of the Accounts API. ```APIDOC ## GET /v1/account ### Description Get information for the connected user account. ### Method GET ### Endpoint /v1/account ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the account details. - **name** (string) - The name of the user. - **address** (string) - The user's address. - **imageUrl** (string, nullable) - URL of the user's profile image. - **referral** (object, nullable) - Referral information. - **code** (string, nullable) - The referral code. - **status** (string, enum: LOCKED, UNLOCKED) - The status of the referral. #### Response Example ```json { "success": true, "data": { "name": "John Doe", "address": "123 Main St, Anytown, USA", "imageUrl": "https://example.com/image.jpg", "referral": { "code": "REF123", "status": "UNLOCKED" } } } ``` ### Security - apiKey (API Key authentication) - jwtAuth (Bearer Token authentication) ``` -------------------------------- ### Create MARKET Sell Order with Predict SDK (TypeScript) Source: https://dev.predict.fun/doc-679306 This snippet demonstrates how to create a MARKET sell order using the Predict SDK in TypeScript. It covers initializing the OrderBuilder, fetching order book data, calculating order amounts, building, signing, and hashing the order. Ensure you have the necessary environment variables and dependencies installed. ```typescript import { Wallet } from "ethers"; import { OrderBuilder, ChainId, Side } from "@predictdotfun/sdk"; // Create a wallet for signing orders const signer = new Wallet(process.env.WALLET_PRIVATE_KEY); // The main function which initiates the OrderBuilder (only once per signer) and then provides it as dependency to other util functions async function main() { // Create a new instance of the OrderBuilder class. Note: This should only be done once per signer const orderBuilder = await OrderBuilder.make(ChainId.BnbMainnet, signer); // Call an helper function to create the order and provide the OrderBuilder instance await createOrder(orderBuilder); } async function createOrder(orderBuilder: OrderBuilder) { // Fetch the orderbook for the specific market via `GET orderbook/{marketId}` const book = {}; /** * NOTE: You can also call `setApprovals` once per wallet. */ // Set all the approval needed within the protocol (if needed) const result = await orderBuilder.setApprovals(); // Check if the approvals were set successfully if (!result.success) { throw new Error("Failed to set approvals."); } // Helper function to calculate the amounts for a `MARKET` order const { lastPrice, pricePerShare, makerAmount, takerAmount } = orderBuilder.getMarketOrderAmounts( { side: Side.SELL, quantityWei: 10000000000000000000n, // 10 shares (in wei) e.g. parseEther("10") }, book, // It's recommended to re-fetch the orderbook regularly to avoid issues ); // Build a limit order (if you are using a Predict account replace `signer.address` with your deposit address) const order = orderBuilder.buildOrder("MARKET", { maker: signer.address, signer: signer.address, side: Side.SELL, // Equivalent to 1 tokenId: "OUTCOME_ON_CHAIN_ID", // This can be fetched via the API or on-chain makerAmount, // 10 shares (in wei) takerAmount, // 0.4 USDT * 10 shares (in wei) nonce: 0n, feeRateBps: 0, // Should be fetched via the `GET /markets` endpoint }); // Build typed data for the order (isNegRisk and isYieldBearing can be fetched via the API) const typedData = orderBuilder.buildTypedData(order, { isNegRisk: false, isYieldBearing: false }); // Sign the order by providing the typedData of the order const signedOrder = await orderBuilder.signTypedDataOrder(typedData); // Compute the order's hash const hash = orderBuilder.buildTypedDataHash(typedData); // Example structure required to create an order via Predict's API const createOrderBody = { data: { order: { ...signedOrder, hash }, pricePerShare, strategy: "MARKET", slippageBps: "200", // Only used for `MARKET` orders, in this example it's 2% }, }; } ``` -------------------------------- ### GET /v1/auth/message Source: https://dev.predict.fun/api-25326899 Retrieves the dynamic message required for signing to generate a JWT token. This message should not be hardcoded as it can change. ```APIDOC ## GET /v1/auth/message ### Description Get the message to sign to generate a JWT token. Do not hardcode this message as it is dynamic and can be subject to changes. ### Method GET ### Endpoint /v1/auth/message ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the data related to the authentication message. - **message** (string) - The message to sign for JWT token generation. #### Response Example ```json { "success": true, "data": { "message": "Please sign this message to authenticate: 0xabc123..." } } ``` ``` -------------------------------- ### GET /llmstxt/dev_predict_fun_llms_txt Source: https://dev.predict.fun/api-25326909 Retrieves detailed information about markets. This endpoint returns a list of markets, each with its unique identifier, title, description, status, and other relevant attributes. ```APIDOC ## GET /llmstxt/dev_predict_fun_llms_txt ### Description Retrieves detailed information about markets. This endpoint returns a list of markets, each with its unique identifier, title, description, status, and other relevant attributes. ### Method GET ### Endpoint /llmstxt/dev_predict_fun_llms_txt ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of markets to return. - **offset** (integer) - Optional - The number of markets to skip before starting to collect the result set. ### Request Body None ### Response #### Success Response (200) - **id** (string) - Unique identifier for the market. - **imageUrl** (string) - URL for the market's image. - **title** (string) - The title of the market. - **question** (string) - The question the market is based on. - **description** (string) - A detailed description of the market. - **status** (string) - The current status of the market (e.g., OPEN, CLOSED). - **isNegRisk** (boolean) - Indicates if the market involves negative risk. - **isYieldBearing** (boolean) - Indicates if the market is yield-bearing. - **feeRateBps** (integer) - The fee rate in basis points. - **resolution** (string) - The resolution of the market. - **oracleQuestionId** (string) - The ID of the oracle question. - **conditionId** (string) - The ID of the market condition. - **resolverAddress** (string) - The address of the market resolver. - **outcomes** (array) - An array of possible outcomes for the market. - **name** (string) - The name of the outcome. - **indexSet** (integer) - The index set for the outcome. - **onChainId** (string) - The on-chain ID for the outcome. - **status** (string) - The status of the outcome (WON, LOST, null). - **questionIndex** (integer) - The index of the question. - **pointAllocationBps** (integer) - Point allocation in basis points. - **spreadThreshold** (number) - The spread threshold for the market. - **shareThreshold** (number) - The share threshold for the market. - **polymarketConditionIds** (array) - An array of Polymarket condition IDs. - (string) - A non-empty string representing a Polymarket condition ID. - **kalshiMarketTicker** (string) - The Kalshi market ticker symbol. - **categorySlug** (string) - The slug for the market category. - **createdAt** (string) - The date and time when the market was created. - **decimalPrecision** (number) - The decimal precision for market values (e.g., 2, 3). #### Response Example ```json { "id": "mkt_123", "imageUrl": "https://example.com/image.png", "title": "Will it rain tomorrow?", "question": "Will there be measurable precipitation in London tomorrow?", "description": "A market to bet on whether it will rain in London tomorrow.", "status": "OPEN", "isNegRisk": false, "isYieldBearing": false, "feeRateBps": 100, "resolution": "https://example.com/resolution.html", "oracleQuestionId": "oq_abc", "conditionId": "cond_xyz", "resolverAddress": "0x123abc", "outcomes": [ { "name": "Yes", "indexSet": 0, "onChainId": "1234567890", "status": "WON" }, { "name": "No", "indexSet": 1, "onChainId": "0987654321", "status": null } ], "questionIndex": 0, "pointAllocationBps": 500, "spreadThreshold": 0.05, "shareThreshold": 0.1, "polymarketConditionIds": ["pm_cond_1", "pm_cond_2"], "kalshiMarketTicker": "RAIN-LON-TOM", "categorySlug": "weather", "createdAt": "2023-10-27T10:00:00Z", "decimalPrecision": 2 } ``` ``` -------------------------------- ### GET /v1/markets Source: https://dev.predict.fun/api-25326905 Retrieves a list of markets with optional filtering. This endpoint allows fetching information about available markets, with parameters to control pagination and filtering. ```APIDOC ## GET /v1/markets ### Description Retrieves a list of markets with optional filtering. This endpoint allows fetching information about available markets, with parameters to control pagination and filtering. ### Method GET ### Endpoint /v1/markets ### Parameters #### Query Parameters - **first** (string) - Optional - a string to be decoded into a number - **after** (string) - Optional - a string ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **success** (boolean) - a boolean - **cursor** (string) - a string, nullable - **data** (array) - An array of market objects: - **id** (number) - a number - **imageUrl** (string) - a non empty string - **title** (string) - a non empty string - **question** (string) - a non empty string - **description** (string) - a non empty string - **status** (string) - enum: REGISTERED, PRICE_PROPOSED, PRICE_DISPUTED, PAUSED, UNPAUSED, RESOLVED - **isNegRisk** (boolean) - a boolean - **isYieldBearing** (boolean) - a boolean - **feeRateBps** (number) - a number - **resolution** (object) - Details about the market resolution, nullable: - **name** (string) - a string - **indexSet** (integer) - an integer - **onChainId** (string) - bigint string - **status** (string) - enum: WON, LOST, nullable - **oracleQuestionId** (string) - a string - **conditionId** (string) - a non empty string - **resolverAddress** (string) - a string - **outcomes** (array) - An array of outcome objects: - **name** (string) - a string - **indexSet** (integer) - an integer - **onChainId** (string) #### Response Example ```json { "success": true, "cursor": "some-cursor-string", "data": [ { "id": 1, "imageUrl": "http://example.com/image.jpg", "title": "Example Market", "question": "Will it rain tomorrow?", "description": "A market to bet on rain tomorrow.", "status": "REGISTERED", "isNegRisk": false, "isYieldBearing": false, "feeRateBps": 10, "resolution": null, "oracleQuestionId": "abc-123", "conditionId": "cond-xyz", "resolverAddress": "0x1234567890abcdef", "outcomes": [ { "name": "Yes", "indexSet": 1, "onChainId": "0x1" }, { "name": "No", "indexSet": 2, "onChainId": "0x2" } ] } ] } ``` ``` -------------------------------- ### GET /v1/markets/{id}/last-sale Source: https://dev.predict.fun/api-25326907 Retrieves the last sale information for a specific market. Requires a market ID as a path parameter. ```APIDOC ## GET /v1/markets/{id}/last-sale ### Description Get the last sale information for a specific market. ### Method GET ### Endpoint /v1/markets/{id}/last-sale ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the market. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the sale details. - **quoteType** (string) - Enum: Ask, Bid - The type of quote for the sale. - **outcome** (string) - Enum: 'Yes', 'No' - The outcome of the sale. - **priceInCurrency** (string) - The price at which the sale occurred, in a specific currency. - **strategy** (string) - Enum: MARKET, LIMIT - The trading strategy used for the sale. #### Response Example ```json { "success": true, "data": { "quoteType": "Ask", "outcome": "Yes", "priceInCurrency": "1.23", "strategy": "MARKET" } } ``` ``` -------------------------------- ### Get Categories Endpoint - OpenAPI 3.0.1 Specification Source: https://dev.predict.fun/api-25326910 This snippet details the GET request for the /v1/categories endpoint. It outlines the available query parameters such as 'first', 'after', and 'status' for filtering and pagination. The response structure includes 'success', 'cursor', and 'data' fields, where 'data' contains detailed information about categories and their markets. ```yaml openapi: 3.0.1 info: title: '' description: '' version: 1.0.0 paths: /v1/categories: get: summary: Get categories deprecated: false description: >- :::info Markets within `RESOLVED` categories are not tradable. You can filter them with the `status` query parameter. ::: Get categories information and their markets operationId: getCategories tags: - Categories - Categories parameters: - name: first in: query description: '' required: false schema: type: string description: a string to be decoded into a number - name: after in: query description: a string required: false schema: type: string description: a string - name: status in: query description: '' required: false schema: type: string enum: - OPEN - RESOLVED responses: '200': description: Response 200 content: application/json: schema: type: object properties: success: type: boolean description: a boolean cursor: type: string description: a string nullable: true data: type: array items: type: object properties: id: type: number description: a number slug: type: string description: a string title: type: string description: a string description: type: string description: a string imageUrl: type: string description: a string isNegRisk: type: boolean description: a boolean isYieldBearing: type: boolean description: a boolean marketVariant: type: string enum: - DEFAULT - SPORTS_MATCH - CRYPTO_UP_DOWN createdAt: type: string description: date string markets: type: array items: type: object properties: id: type: number description: a number imageUrl: type: string description: a non empty string minLength: 1 title: type: string description: a non empty string minLength: 1 question: type: string description: a non empty string minLength: 1 description: type: string description: a non empty string minLength: 1 status: type: string enum: - REGISTERED - PRICE_PROPOSED - PRICE_DISPUTED - PAUSED - UNPAUSED - RESOLVED isNegRisk: type: boolean description: a boolean isYieldBearing: type: boolean description: a boolean feeRateBps: type: number description: a number resolution: type: object properties: ``` -------------------------------- ### JSON Order Book API Response Structure Source: https://dev.predict.fun/doc-685654 This is an example of the JSON response structure from the order book API. It includes market details and lists of buy ('bids') and sell ('asks') prices for the 'Yes' outcome, each with price and quantity. ```json { "success": true, "data": { "marketId": 1, "updateTimestampMs": 1727910141000, "asks": [ [0.492, 30192.26], [0.493, 20003] ], "bids": [ [0.491, 303518.1], [0.49, 1365.44] ] } } ``` -------------------------------- ### GET /v1/markets/{id}/stats Source: https://dev.predict.fun/api-25326906 Retrieves statistics about a specific market. This endpoint requires a market ID as a path parameter and returns detailed statistics including total liquidity and volume. ```APIDOC ## GET /v1/markets/{id}/stats ### Description Get statistics about a specific market. ### Method GET ### Endpoint /v1/markets/{id}/stats ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the market to retrieve statistics for. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the market statistics. - **totalLiquidityUsd** (number) - The total liquidity of the market in USD. - **volumeTotalUsd** (number) - The total trading volume of the market in USD. - **volume24hUsd** (number) - The trading volume of the market in USD over the last 24 hours. #### Response Example ```json { "success": true, "data": { "totalLiquidityUsd": 1000000.50, "volumeTotalUsd": 500000.75, "volume24hUsd": 15000.25 } } ``` ``` -------------------------------- ### POST /v1/auth - Get JWT with valid signature Source: https://dev.predict.fun/api-25326900 Provides a signature and returns a valid JWT that allows order actions. This endpoint is used for obtaining authentication tokens. ```APIDOC ## POST /v1/auth ### Description Provide a signature and get back a valid JWT that allows order actions. ### Method POST ### Endpoint /v1/auth #### Request Body - **signer** (string) - Required - a string - **signature** (string) - Required - a string - **message** (string) - Required - a string ### Request Example ```json { "signer": "string", "signature": "string", "message": "string" } ``` ### Response #### Success Response (200) - **success** (boolean) - a boolean - **data** (object) - Description for data - **token** (string) - a string #### Response Example ```json { "success": true, "data": { "token": "string" } } ``` ``` -------------------------------- ### Get Market Data API Source: https://dev.predict.fun/api-25326911 Retrieves detailed information about prediction markets, including their status, risk factors, and associated metadata. Supports filtering and sorting. ```APIDOC ## GET /llmstxt/dev_predict_fun_llms_txt ### Description Retrieves a list of prediction markets with detailed information. This endpoint allows fetching data related to various aspects of prediction markets, including questions, descriptions, statuses, risk assessments, fees, resolution details, and associated IDs. ### Method GET ### Endpoint /llmstxt/dev_predict_fun_llms_txt ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of results to return. - **offset** (integer) - Optional - The number of results to skip before starting to collect the result set. - **sortBy** (string) - Optional - The field to sort the results by. Example: 'createdAt'. - **order** (string) - Optional - The order of sorting. 'asc' for ascending, 'desc' for descending. ### Request Example ``` GET /llmstxt/dev_predict_fun_llms_txt?limit=10&sortBy=createdAt&order=desc ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the list of prediction markets and their details. - **question** (string) - The question posed by the prediction market. - **description** (string) - A detailed description of the prediction market. - **status** (string) - The current status of the market (e.g., OPEN, RESOLVED). - **isNegRisk** (boolean) - Indicates if the market involves negative risk. - **isYieldBearing** (boolean) - Indicates if the market is yield-bearing. - **feeRateBps** (integer) - The fee rate in basis points. - **resolution** (string) - The resolution of the market if resolved. - **oracleQuestionId** (string) - The ID of the oracle question. - **conditionId** (string) - The ID of the condition. - **resolverAddress** (string) - The address of the resolver. - **outcomes** (array) - A list of possible outcomes for the market. - **questionIndex** (integer) - The index of the question. - **pointAllocationBps** (integer) - The point allocation in basis points. - **spreadThreshold** (number) - The spread threshold for the market. - **shareThreshold** (number) - The share threshold for the market. - **polymarketConditionIds** (array) - List of Polymarket condition IDs. - **kalshiMarketTicker** (string) - The Kalshi market ticker symbol. - **categorySlug** (string) - The slug for the market's category. - **createdAt** (string) - The timestamp when the market was created. - **startsAt** (string) - The timestamp when the market starts. - **tags** (array) - An array of tags associated with the market. - **id** (string) - The ID of the tag. - **name** (string) - The name of the tag. #### Response Example ```json { "success": true, "data": [ { "id": "123", "slug": "will-eth-2000-by-december", "title": "Will ETH reach $2000 by December?", "description": "Predict whether the price of Ethereum will reach or exceed $2000 before December 31st, 2023.", "imageUrl": "https://example.com/eth.png", "isNegRisk": false, "isYieldBearing": true, "marketVariant": "binary", "createdAt": "2023-10-27T10:00:00Z", "startsAt": { "type": "string", "description": "date string" }, "status": "OPEN", "tags": [ { "id": "crypto", "name": "Cryptocurrency" } ], "question": "Will ETH be >= $2000 on 2023-12-31?", "feeRateBps": 200, "resolution": null, "oracleQuestionId": "oracle-q-456", "conditionId": "cond-789", "resolverAddress": "0xabc...", "outcomes": ["YES", "NO"], "questionIndex": 0, "pointAllocationBps": 10000, "spreadThreshold": 0.05, "shareThreshold": 0.5, "polymarketConditionIds": ["pm-cond-1", "pm-cond-2"], "kalshiMarketTicker": "ETHUSD", "categorySlug": "crypto", "decimalPrecision": 2 } ] } ``` ``` -------------------------------- ### GET /v1/categories Source: https://dev.predict.fun/api-25326910 Retrieves a list of categories and their associated markets. Supports filtering by category status and pagination. ```APIDOC ## GET /v1/categories ### Description Retrieves a list of categories and their associated markets. Markets within `RESOLVED` categories are not tradable. You can filter them with the `status` query parameter. ### Method GET ### Endpoint /v1/categories ### Parameters #### Query Parameters - **first** (string) - Optional - a string to be decoded into a number - **after** (string) - Optional - a string - **status** (string) - Optional - Enum: OPEN, RESOLVED ### Response #### Success Response (200) - **success** (boolean) - a boolean - **cursor** (string) - a string (nullable) - **data** (array) - Array of category objects: - **id** (number) - a number - **slug** (string) - a string - **title** (string) - a string - **description** (string) - a string - **imageUrl** (string) - a string - **isNegRisk** (boolean) - a boolean - **isYieldBearing** (boolean) - a boolean - **marketVariant** (string) - Enum: DEFAULT, SPORTS_MATCH, CRYPTO_UP_DOWN - **createdAt** (string) - date string - **markets** (array) - Array of market objects: - **id** (number) - a number - **imageUrl** (string) - a non empty string - **title** (string) - a non empty string - **question** (string) - a non empty string - **description** (string) - a non empty string - **status** (string) - Enum: REGISTERED, PRICE_PROPOSED, PRICE_DISPUTED, PAUSED, UNPAUSED, RESOLVED - **isNegRisk** (boolean) - a boolean - **isYieldBearing** (boolean) - a boolean - **feeRateBps** (number) - a number - **resolution** (object) - object describing resolution details #### Response Example ```json { "success": true, "cursor": "string", "data": [ { "id": 1, "slug": "example-slug", "title": "Example Category", "description": "This is an example category.", "imageUrl": "https://example.com/image.jpg", "isNegRisk": false, "isYieldBearing": false, "marketVariant": "DEFAULT", "createdAt": "2023-10-27T10:00:00Z", "markets": [ { "id": 101, "imageUrl": "https://example.com/market.jpg", "title": "Example Market", "question": "Will it rain tomorrow?", "description": "A market about tomorrow's weather.", "status": "OPEN", "isNegRisk": false, "isYieldBearing": false, "feeRateBps": 50, "resolution": {} } ] } ] } ``` ```