如何获取Polymarket平台Bitcoin Up or Down - 5 Minutes的Price to Beat数值?
Hey there! I’ve messed around with Polymarket’s market data a fair bit over time, so here are a few reliable, no-external-link ways to grab that Price to Beat value for the 5-minute Bitcoin Up/Down market:
Quick frontend scrape (great for one-off checks)
If you just need the value once or don’t want to dive into code, use your browser’s dev tools:- Open the Polymarket page for the 5-minute Bitcoin Up/Down market.
- Right-click anywhere on the page > Inspect to open dev tools.
- Head to the "Elements" tab, then use the search bar (Ctrl+F) to look for terms like
price-to-beator scan for the element displaying the labeled "Price to Beat" value. - If you want to automate this a little, pop open the "Console" tab and run a simple JS snippet to extract it—for example, if the value is in a span with a class like
market-reference-price, run:document.querySelector('.market-reference-price').textContent
Note: Class names might change occasionally, so you’ll need to double-check the selector if it stops working.
Fetch directly from the on-chain smart contract (most reliable for long-term use)
All Polymarket markets are backed by on-chain contracts, and the Price to Beat is just the reference BTC price fed by an oracle (usually Chainlink) to the market contract. Here’s how to get it:- Grab the market’s contract address from the Polymarket page—look in the "Market Info" section for the "Contract Address" field and copy it.
- Use a blockchain explorer (like the one for Base, since Polymarket uses this chain for most short-term markets) to read the contract’s state. Look for public view functions or variables named
priceToBeat,referencePrice, orsettlementThreshold—these will return the raw value. - If you’re coding, use a library like Ethers.js or Viem to call the contract without spending gas. Here’s a quick Viem example:
import { createPublicClient, http } from 'viem' import { base } from 'viem/chains' // Initialize a public client for Base chain const publicClient = createPublicClient({ chain: base, transport: http(), }) // Replace with the actual 5min BTC market contract address const marketAddress = '0x...' // ABI snippet for the price-to-beat view function const marketABI = [ { "inputs": [], "name": "priceToBeat", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" } ] // Fetch the raw value (it's in 8-decimal format for BTC) const rawPriceToBeat = await publicClient.readContract({ address: marketAddress, abi: marketABI, functionName: 'priceToBeat' }) // Convert to a human-readable USD price const humanReadablePrice = Number(rawPriceToBeat) / 1e8 console.log(`Price to Beat: $${humanReadablePrice.toFixed(2)}`)
The decimal precision is almost always 8 for BTC-related markets on Polymarket, so dividing by
1e8will get you the standard USD price.Use Polymarket’s internal data endpoints (good for real-time automation)
While Polymarket doesn’t officially document these, their frontend pulls data from internal API endpoints that you can replicate. Here’s how to find and use them:- With the 5min BTC market page open, go to your browser’s "Network" tab in dev tools.
- Filter for "XHR" requests, then refresh the page. Look for requests that return a JSON object with market details (like one named something like
market/[market-id]). - Check the response body—you’ll find the Price to Beat under a key like
priceToBeatorreferencePrice. - You can call this same endpoint in your code using tools like
fetchoraxios—no API key required for public market data. Just keep in mind: these endpoints are unofficial, so they might change without warning, but they’ve been stable for short-term BTC markets for a while now.
If you run into any issues with any of these methods—like finding the right contract function or selector—feel free to follow up with more details, and I’ll help you troubleshoot!




