manifold

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Manifold API

Manifold API

Manifold is a prediction market platform where users create and trade on questions about real-world events. It uses a combination of play-money (mana) and prize-cash, with automated market makers (CPMM) and a rich API for programmatic access.
Check this skill and the official documentation FREQUENTLY for updates. The API is still in alpha and may change without notice.
Community: Join the Manifold Discord for questions, bug reports, and to share what you build.
Source code: Manifold is open source. Type definitions live at common/src/api/schema.ts.

Manifold是一个预测市场平台,用户可在此创建并交易与现实世界事件相关的问题。它结合了虚拟货币(Mana)和奖励现金机制,采用自动做市商(CPMM),并提供功能丰富的API供程序化访问。
定期查看本技能及官方文档以获取更新。目前API仍处于alpha阶段,可能会在无通知的情况下变更。
社区: 加入Manifold Discord以提问、提交Bug报告,以及分享你的开发成果。
源代码: Manifold是开源项目。类型定义文件位于common/src/api/schema.ts

Key Concepts (Glossary)

核心概念(术语表)

TermDefinition
Market (Contract)A single tradeable question. Called "contract" in the codebase, "market" in the API. Has an outcome type (BINARY, MULTIPLE_CHOICE, PSEUDO_NUMERIC, BOUNTIED_QUESTION, POLL).
Mana (M$)Play-money currency used for most markets. Cannot be withdrawn for real money.
Prize Cash (CASH)Real-money currency available on select markets. Can be withdrawn. Identified by
token: "CASH"
on a market.
Sibling ContractThe mana or prize-cash counterpart of a market. Toggle between them via
siblingContractId
.
Topic (Group)A tag applied to markets for categorization. Called "group" in the codebase and API.
CPMMConstant Product Market Maker. The automated market maker used for binary (
cpmm-1
) and multi-answer (
cpmm-multi-1
) markets.
DPMDynamic Parimutuel Market — a legacy mechanism (
dpm-2
) used for older free-response markets.
ProbabilityA number between 0 and 1 representing the market's current implied probability of YES.
PoolThe liquidity pool of shares backing the market maker. For CPMM markets, shows YES and NO share counts.
LiquidityMana deposited into the AMM pool. More liquidity means less price impact per trade.
BetA trade on a market. Can be a market order or a limit order (when
limitProb
is specified).
Limit OrderA bet that only executes at a specified probability price or better. Remains open until filled, cancelled, or expired.
SharesUnits of a position. Winning YES shares pay out M$1 each; losing shares pay M$0.
ResolutionThe final outcome of a market: YES, NO, MKT (probability), or CANCEL.
AnswerA possible outcome in a MULTIPLE_CHOICE or FREE_RESPONSE market. Each answer has its own probability.
BountyA BOUNTIED_QUESTION market where the creator distributes mana rewards to the best comments/answers.
PollA non-trading market type where users simply vote on options.

术语定义
Market(合约)单个可交易的问题。在代码库中称为“contract”,在API中称为“market”。包含结果类型(BINARY、MULTIPLE_CHOICE、PSEUDO_NUMERIC、BOUNTIED_QUESTION、POLL)。
Mana(M$)大多数市场使用的虚拟货币,无法兑换为真实货币。
奖励现金(CASH)部分特定市场可用的真实货币,可以提现。在市场中通过
token: "CASH"
标识。
Sibling Contract某个市场对应的Mana或奖励现金版本。可通过
siblingContractId
在两者间切换。
Topic(Group)用于市场分类的标签。在代码库和API中称为“group”。
CPMM恒定乘积做市商。用于二元市场(
cpmm-1
)和多选项市场(
cpmm-multi-1
)的自动做市商机制。
DPM动态 pari-mutuel 市场——一种用于旧版自由回答市场的遗留机制(
dpm-2
)。
Probability0到1之间的数值,代表市场当前隐含的YES结果概率。
Pool支持做市商的份额流动性池。对于CPMM市场,显示YES和NO的份额数量。
Liquidity存入AMM池的Mana。流动性越高,每次交易对价格的影响越小。
Bet市场中的一笔交易。可以是市价单,也可以是限价单(当指定
limitProb
时)。
Limit Order仅在指定概率价格或更优价格下执行的订单。未成交部分会保持挂单状态,直到成交、取消或过期。
Shares持仓的单位。获胜的YES份额每份支付M$1;失败的份额支付M$0。
Resolution市场的最终结果:YES、NO、MKT(概率)或CANCEL。
AnswerMULTIPLE_CHOICE或FREE_RESPONSE市场中的一个可能结果。每个答案都有独立的概率。
BountyBOUNTIED_QUESTION类型的市场,创建者会向最佳评论/答案发放Mana奖励。
Poll非交易类市场,用户仅能对选项进行投票。

Base URLs

基础URL

EnvironmentREST APIWebSocket
Production
https://api.manifold.markets
wss://api.manifold.markets/ws
Dev
https://api.dev.manifold.markets
wss://api.dev.manifold.markets/ws
Important: The API was recently moved from
https://manifold.markets/api
to
https://api.manifold.markets
. The old domain will be removed in the future. Always use the new domain.
All REST endpoints are prefixed with
/v0/
.

环境REST APIWebSocket
生产环境
https://api.manifold.markets
wss://api.manifold.markets/ws
开发环境
https://api.dev.manifold.markets
wss://api.dev.manifold.markets/ws
重要提示: API最近已从
https://manifold.markets/api
迁移至
https://api.manifold.markets
。旧域名将在未来停用,请始终使用新域名。
所有REST端点均以
/v0/
为前缀。

Documentation & References

文档与参考资源

Authentication

身份验证

Some endpoints are public (no auth required). Write endpoints and user-specific reads require authentication via an API key.
部分端点为公开访问(无需验证)。写入类端点和用户专属读取类端点需要通过API密钥进行身份验证。

Generating an API Key

生成API密钥

  1. Log in to Manifold.
  2. Go to your user profile and click "edit".
  3. Scroll to the API key field at the bottom.
  4. Click the "refresh" button to generate a new key.
  5. Copy and store the key securely. Clicking refresh again will invalidate the old key and generate a new one.
  1. 登录Manifold
  2. 进入个人资料页面并点击“编辑”。
  3. 滚动至页面底部的API密钥区域。
  4. 点击“刷新”按钮生成新密钥。
  5. 复制并安全存储密钥。再次点击刷新会使旧密钥失效并生成新密钥。

Using the API Key

使用API密钥

Include the key in the
Authorization
header:
Authorization: Key {your_api_key}
Alternatively, the API accepts Firebase JWTs via
Authorization: Bearer {jwt}
, but this is intended for the web client and not recommended for third-party use.
Authorization
请求头中包含密钥:
Authorization: Key {your_api_key}
此外,API也支持通过
Authorization: Bearer {jwt}
传入Firebase JWT,但该方式仅适用于Web客户端,不推荐第三方使用。

Example Authenticated Request

身份验证请求示例

bash
curl "https://api.manifold.markets/v0/me" \
  -H "Authorization: Key YOUR_API_KEY"

bash
curl "https://api.manifold.markets/v0/me" \
  -H "Authorization: Key YOUR_API_KEY"

Rate Limits

请求频率限制

There is a rate limit of 500 requests per minute per IP address. Do not use multiple IP addresses to circumvent this limit.
Implement exponential backoff on HTTP 429 responses.

每个IP地址的请求频率限制为每分钟500次。请勿使用多个IP地址规避此限制。
收到HTTP 429响应时,请实现指数退避机制。

Fees

费用

  • Comments placed through the API incur a M$1 transaction fee.
  • Market creation costs mana (see the market creation endpoint for current costs per type).

  • 通过API发布评论会产生M$1的交易费用。
  • 创建市场需要消耗Mana(具体费用请查看市场创建端点的说明)。

Licensing

授权许可

  • Permitted: Bots, automated trading, algorithmic tools, integrations.
  • Prohibited: Scraping through means other than the API; circumventing rate limits.
  • AI training data: Not permitted for commercial use without a data license. Academic and personal/non-commercial use is allowed. Contact
    api@manifold.markets
    for commercial licensing.

  • 允许用途: 机器人、自动化交易、算法工具、集成开发。
  • 禁止用途: 通过API以外的方式进行数据爬取;规避请求频率限制。
  • AI训练数据: 未经数据授权,禁止用于商业用途。学术研究和个人/非商业用途是允许的。如需商业授权,请联系
    api@manifold.markets

REST API Endpoints Overview

REST API端点概述

All endpoints are relative to
https://api.manifold.markets/v0
.
所有端点均基于
https://api.manifold.markets/v0

Users

用户相关

EndpointMethodAuthDescription
/user/[username]
GETNoGet a user by username. Returns
User
.
/user/[username]/lite
GETNoGet basic display info by username. Returns
DisplayUser
.
/user/by-id/[id]
GETNoGet a user by unique ID. Returns
User
.
/user/by-id/[id]/lite
GETNoGet display info by ID. Returns
DisplayUser
.
/me
GETYesGet the authenticated user. Returns
User
.
/users
GETNoList all users, ordered by creation date desc. Params:
limit
(max 1000, default 500),
before
(user ID for pagination).
端点方法身份验证描述
/user/[username]
GET通过用户名获取用户信息,返回
User
类型。
/user/[username]/lite
GET通过用户名获取基础展示信息,返回
DisplayUser
类型。
/user/by-id/[id]
GET通过唯一ID获取用户信息,返回
User
类型。
/user/by-id/[id]/lite
GET通过ID获取展示信息,返回
DisplayUser
类型。
/me
GET获取当前已验证用户的信息,返回
User
类型。
/users
GET按创建时间降序列出所有用户。参数:
limit
(最大1000,默认500)、
before
(用于分页的用户ID)。

User Type

User类型

User {
  id: string
  createdTime: number
  name: string              // display name
  username: string           // used in URLs
  url: string
  avatarUrl?: string
  bio?: string
  bannerUrl?: string
  website?: string
  twitterHandle?: string
  discordHandle?: string
  isBot?: boolean
  isAdmin?: boolean
  isTrustworthy?: boolean    // moderator
  isBannedFromPosting?: boolean
  userDeleted?: boolean
  balance: number
  totalDeposits: number
  lastBetTime?: number
  currentBettingStreak?: number
}
User {
  id: string
  createdTime: number
  name: string              // 显示名称
  username: string           // URL中使用的用户名
  url: string
  avatarUrl?: string
  bio?: string
  bannerUrl?: string
  website?: string
  twitterHandle?: string
  discordHandle?: string
  isBot?: boolean
  isAdmin?: boolean
  isTrustworthy?: boolean    // 版主
  isBannedFromPosting?: boolean
  userDeleted?: boolean
  balance: number
  totalDeposits: number
  lastBetTime?: number
  currentBettingStreak?: number
}

DisplayUser Type

DisplayUser类型

DisplayUser {
  id: string
  name: string
  username: string
  avatarUrl?: string
}
DisplayUser {
  id: string
  name: string
  username: string
  avatarUrl?: string
}

Portfolio

投资组合相关

EndpointMethodAuthDescription
/get-user-portfolio
GETNoGet a user's live portfolio metrics. Param:
userId
.
/get-user-portfolio-history
GETNoGet portfolio history over a period. Params:
userId
,
period
(
daily
,
weekly
,
monthly
,
allTime
).
/get-user-contract-metrics-with-contracts
GETNo*Get a user's positions and their contracts. Params:
userId
(required),
limit
(required),
offset
,
order
(
lastBetTime
or
profit
),
perAnswer
. *When authenticated, may include private market metrics visible to you.
端点方法身份验证描述
/get-user-portfolio
GET获取用户的实时投资组合指标。参数:
userId
/get-user-portfolio-history
GET获取用户在指定时间段内的投资组合历史。参数:
userId
period
daily
weekly
monthly
allTime
)。
/get-user-contract-metrics-with-contracts
GET否*获取用户的持仓及对应市场信息。参数:
userId
(必填)、
limit
(必填)、
offset
order
lastBetTime
profit
)、
perAnswer
。 *已验证用户可查看自己可见的私有市场指标。

PortfolioMetrics Type

PortfolioMetrics类型

PortfolioMetrics {
  investmentValue: number
  cashInvestmentValue: number
  balance: number
  cashBalance: number
  spiceBalance: number
  totalDeposits: number
  totalCashDeposits: number
  loanTotal: number
  timestamp: number
  profit?: number
  userId: string
}

LivePortfolioMetrics = PortfolioMetrics & {
  dailyProfit: number
}
PortfolioMetrics {
  investmentValue: number
  cashInvestmentValue: number
  balance: number
  cashBalance: number
  spiceBalance: number
  totalDeposits: number
  totalCashDeposits: number
  loanTotal: number
  timestamp: number
  profit?: number
  userId: string
}

LivePortfolioMetrics = PortfolioMetrics & {
  dailyProfit: number
}

Markets — Discovery & Listing

市场 — 发现与列表

EndpointMethodAuthDescription
/markets
GETNoList markets by creation date desc. Params:
limit
(max 1000, default 500),
sort
(
created-time
,
updated-time
,
last-bet-time
,
last-comment-time
),
order
(
asc
/
desc
),
before
(market ID for cursor pagination),
userId
,
groupId
. Returns
LiteMarket[]
.
/market/[marketId]
GETNoGet a single market by ID. Returns
FullMarket
(includes answers, but not bets/comments).
/slug/[marketSlug]
GETNoGet a market by slug (URL path after username). Returns
FullMarket
.
/search-markets
GETNoSearch/filter markets (similar to browse page). Returns
LiteMarket[]
. See parameters below.
端点方法身份验证描述
/markets
GET按创建时间降序列出市场。参数:
limit
(最大1000,默认500)、
sort
created-time
updated-time
last-bet-time
last-comment-time
)、
order
asc
/
desc
)、
before
(用于游标分页的市场ID)、
userId
groupId
。返回
LiteMarket[]
/market/[marketId]
GET通过ID获取单个市场的详细信息,返回
FullMarket
(包含答案,但不包含交易/评论)。
/slug/[marketSlug]
GET通过slug(用户名后的URL路径)获取市场信息,返回
FullMarket
/search-markets
GET搜索/筛选市场(与平台浏览页逻辑类似),返回
LiteMarket[]
。参数详情见下方。

Search Markets Parameters

搜索市场参数

ParameterDescription
term
Search query string. Can be empty.
sort
most-popular
(default),
newest
,
score
,
daily-score
,
freshness-score
,
24-hour-vol
,
liquidity
,
subsidy
,
last-updated
,
close-date
,
start-time
,
resolve-date
,
random
,
bounty-amount
,
prob-descending
,
prob-ascending
.
filter
all
(default),
open
,
closed
,
resolved
,
news
,
closing-90-days
,
closing-week
,
closing-month
,
closing-day
.
contractType
ALL
(default),
BINARY
,
MULTIPLE_CHOICE
,
DEPENDENT_MULTIPLE_CHOICE
,
INDEPENDENT_MULTIPLE_CHOICE
,
BOUNTY
,
POLL
.
topicSlug
Only markets tagged with this topic slug.
creatorId
Only markets by this creator.
limit
0–1000 (default 100).
offset
Number to skip (max 1000 when
sort=newest
).
beforeTime
Millisecond timestamp cursor for efficient pagination with
sort=newest
. Pass
createdTime
of last result.
liquidity
Minimum liquidity per contract/answer.
参数描述
term
搜索查询字符串,可为空。
sort
most-popular
(默认)、
newest
score
daily-score
freshness-score
24-hour-vol
liquidity
subsidy
last-updated
close-date
start-time
resolve-date
random
bounty-amount
prob-descending
prob-ascending
filter
all
(默认)、
open
closed
resolved
news
closing-90-days
closing-week
closing-month
closing-day
contractType
ALL
(默认)、
BINARY
MULTIPLE_CHOICE
DEPENDENT_MULTIPLE_CHOICE
INDEPENDENT_MULTIPLE_CHOICE
BOUNTY
POLL
topicSlug
仅返回带有该主题slug的市场。
creatorId
仅返回该创建者创建的市场。
limit
0–1000(默认100)。
offset
跳过的结果数量(当
sort=newest
时最大为1000)。
beforeTime
毫秒级时间戳游标,配合
sort=newest
实现高效分页,传入上一页最后一条结果的
createdTime
liquidity
每个合约/答案的最低流动性要求。

Markets — Probabilities

市场 — 概率相关

EndpointMethodAuthDescription
/market/[marketId]/prob
GETNoGet current probability (max 1s cache). Returns
{ prob }
for binary or
{ answerProbs: { answerId: prob } }
for multi.
/market-probs
GETNoBatch probabilities for multiple markets (max 1s cache). Param:
ids
(array, up to 100). Returns `{ marketId: { prob }
端点方法身份验证描述
/market/[marketId]/prob
GET获取市场当前的概率(最大1秒缓存)。二元市场返回
{ prob }
,多选项市场返回
{ answerProbs: { answerId: prob } }
/market-probs
GET批量获取多个市场的概率(最大1秒缓存)。参数:
ids
(数组,最多100个)。返回`{ marketId: { prob }

Markets — Positions

市场 — 持仓相关

EndpointMethodAuthDescription
/market/[marketId]/positions
GETNoGet position data for a market. Params:
order
(
shares
/
profit
, default
profit
),
top
,
bottom
,
userId
,
answerId
. Returns
ContractMetric[]
.
端点方法身份验证描述
/market/[marketId]/positions
GET获取市场的持仓数据。参数:
order
shares
/
profit
,默认
profit
)、
top
bottom
userId
answerId
。返回
ContractMetric[]

ContractMetric Type

ContractMetric类型

ContractMetric {
  contractId: string
  from: {
    [period: string]: {     // day, week, month
      profit: number
      profitPercent: number
      invested: number
      prevValue: number
      value: number
    }
  } | undefined
  hasNoShares: boolean
  hasShares: boolean
  hasYesShares: boolean
  invested: number
  loan: number
  maxSharesOutcome: string | null
  payout: number
  profit: number
  profitPercent: number
  totalShares: { [outcome: string]: number }
  userId: string
  userUsername: string
  userName: string
  userAvatarUrl: string
  lastBetTime: number
}
ContractMetric {
  contractId: string
  from: {
    [period: string]: {     // day, week, month
      profit: number
      profitPercent: number
      invested: number
      prevValue: number
      value: number
    }
  } | undefined
  hasNoShares: boolean
  hasShares: boolean
  hasYesShares: boolean
  invested: number
  loan: number
  maxSharesOutcome: string | null
  payout: number
  profit: number
  profitPercent: number
  totalShares: { [outcome: string]: number }
  userId: string
  userUsername: string
  userName: string
  userAvatarUrl: string
  lastBetTime: number
}

Markets — Creation & Management

市场 — 创建与管理

EndpointMethodAuthDescription
/market
POSTYesCreate a new market. Returns
LiteMarket
. See parameters below.
/market/[marketId]/answer
POSTYesAdd an answer to a MULTIPLE_CHOICE market. Param:
text
.
/market/[marketId]/add-liquidity
POSTYesAdd mana to liquidity pool (does not boost). Param:
amount
.
/market/[marketId]/add-bounty
POSTYesAdd mana to a bounty question's reward. Param:
amount
.
/market/[marketId]/award-bounty
POSTYesDistribute bounty reward. Params:
amount
,
commentId
.
/market/[marketId]/close
POSTYesSet close time. Param:
closeTime
(ms since epoch; omit to close immediately).
/market/[marketId]/group
POSTYesAdd/remove a topic tag. Params:
groupId
,
remove
(optional,
true
to untag).
/market/[marketId]/resolve
POSTYesResolve a market. See resolution format below.
端点方法身份验证描述
/market
POST创建新市场,返回
LiteMarket
。参数详情见下方。
/market/[marketId]/answer
POST为MULTIPLE_CHOICE类型的市场添加答案。参数:
text
/market/[marketId]/add-liquidity
POST向流动性池存入Mana(不会获得额外奖励)。参数:
amount
/market/[marketId]/add-bounty
POST为悬赏问题的奖励池添加Mana。参数:
amount
/market/[marketId]/award-bounty
POST发放悬赏奖励。参数:
amount
commentId
/market/[marketId]/close
POST设置市场关闭时间。参数:
closeTime
(自纪元起的毫秒数;留空则立即关闭)。
/market/[marketId]/group
POST添加/移除主题标签。参数:
groupId
remove
(可选,
true
表示移除标签)。
/market/[marketId]/resolve
POST结算市场,结算格式见下方说明。

Market Creation Parameters

市场创建参数

Common parameters (all market types):
ParameterRequiredDescription
outcomeType
Yes
BINARY
,
MULTIPLE_CHOICE
,
PSEUDO_NUMERIC
,
POLL
,
BOUNTIED_QUESTION
.
question
YesThe headline question.
description
NoPlain text description. Or use
descriptionHtml
,
descriptionMarkdown
, or
descriptionJson
(stringified TipTap JSON).
closeTime
NoWhen the market closes (ms since epoch). Defaults to 7 days from now.
visibility
No
public
(default) or
unlisted
.
groupIds
NoArray of topic IDs to tag.
extraLiquidity
NoAdditional liquidity to add.
Additional parameters by type:
TypeExtra Parameters
BINARY
initialProb
(1–99, required)
PSEUDO_NUMERIC
min
,
max
,
isLogScale
,
initialValue
(all required)
MULTIPLE_CHOICE
answers
(string[], required),
addAnswersMode
(
DISABLED
/
ONLY_CREATOR
/
ANYONE
, default
DISABLED
),
shouldAnswersSumToOne
(boolean)
BOUNTIED_QUESTION
totalBounty
(required)
POLL
answers
(string[], required)
Creation costs:
TypeCost
BINARYM$50
PSEUDO_NUMERICM$250
MULTIPLE_CHOICEM$25/answer or M$25 for no preset answers
所有市场类型的通用参数:
参数是否必填描述
outcomeType
BINARY
MULTIPLE_CHOICE
PSEUDO_NUMERIC
POLL
BOUNTIED_QUESTION
question
市场的核心问题标题。
description
纯文本描述。也可使用
descriptionHtml
descriptionMarkdown
descriptionJson
(字符串化的TipTap JSON)。
closeTime
市场关闭时间(自纪元起的毫秒数),默认创建后7天关闭。
visibility
public
(默认)或
unlisted
groupIds
要添加的主题ID数组。
extraLiquidity
额外添加的流动性。
按类型区分的额外参数:
类型额外参数
BINARY
initialProb
(1–99,必填)
PSEUDO_NUMERIC
min
max
isLogScale
initialValue
(均必填)
MULTIPLE_CHOICE
answers
(字符串数组,必填)、
addAnswersMode
DISABLED
/
ONLY_CREATOR
/
ANYONE
,默认
DISABLED
)、
shouldAnswersSumToOne
(布尔值)
BOUNTIED_QUESTION
totalBounty
(必填)
POLL
answers
(字符串数组,必填)
创建成本:
类型成本
BINARYM$50
PSEUDO_NUMERICM$250
MULTIPLE_CHOICE每个答案M$25,无预设答案则为M$25

Resolution Formats

结算格式

Binary markets:
  • outcome
    :
    YES
    ,
    NO
    ,
    MKT
    , or
    CANCEL
    .
  • probabilityInt
    : Optional, used when resolving to
    MKT
    .
Multiple Choice (shouldAnswersSumToOne = true):
{
  "outcome": "MKT",
  "resolutions": [
    { "answer": <index>, "pct": <weight> }
  ]
}
Weights must sum to 100. Or use
outcome
as a number for a single answer index, or
CANCEL
.
Multiple Choice (shouldAnswersSumToOne = false): Resolve each answer independently with separate requests:
{
  "outcome": "YES",    // or "NO"
  "answerId": "<answer_id>"
}
Numeric markets:
  • outcome
    :
    CANCEL
    or a numeric bucket ID.
  • value
    : The resolution value.
  • probabilityInt
    : Required if
    value
    is provided.
二元市场:
  • outcome
    :
    YES
    NO
    MKT
    CANCEL
  • probabilityInt
    : 可选,结算为
    MKT
    时使用。
多选项市场(shouldAnswersSumToOne = true):
{
  "outcome": "MKT",
  "resolutions": [
    { "answer": <index>, "pct": <weight> }
  ]
}
权重总和必须为100。也可将
outcome
设为单个答案的索引,或设为
CANCEL
多选项市场(shouldAnswersSumToOne = false): 需通过单独请求为每个答案独立结算:
{
  "outcome": "YES",    // 或"NO"
  "answerId": "<answer_id>"
}
数值型市场:
  • outcome
    :
    CANCEL
    或某个数值区间的ID。
  • value
    : 结算的具体数值。
  • probabilityInt
    : 提供
    value
    时必填。

Trading

交易相关

EndpointMethodAuthDescription
/bet
POSTYesPlace a bet or limit order. Returns
Bet
.
/multi-bet
POSTYesPlace multiple YES bets on a sums-to-one multi-choice market, targeting equal shares per answer. Returns
Bet[]
.
/bet/cancel/[id]
POSTYesCancel an open limit order.
/market/[marketId]/sell
POSTYesSell shares. Params:
outcome
(
YES
/
NO
, defaults to kind held),
shares
(optional, defaults to all),
answerId
(required for multi-choice).
端点方法身份验证描述
/bet
POST下单交易或限价单,返回
Bet
/multi-bet
POST在总和为1的多选项市场中下单多个YES交易,目标为每个答案持有相等份额,返回
Bet[]
/bet/cancel/[id]
POST取消未成交的限价单。
/market/[marketId]/sell
POST卖出份额。参数:
outcome
YES
/
NO
,默认持有份额的类型)、
shares
(可选,默认卖出全部)、
answerId
(多选项市场必填)。

Bet Parameters

Bet参数

ParameterRequiredDescription
amount
YesAmount in mana to bet, before fees.
contractId
YesThe market ID.
outcome
No
YES
(default) or
NO
.
limitProb
NoMakes this a limit order. A number from 0.01 to 0.99 (whole percentage points only, e.g., 0.01 = 1%).
expiresAt
NoTimestamp (ms) when the limit order auto-cancels.
expiresMillisAfter
NoMilliseconds after creation for auto-cancel.
dryRun
NoIf
true
, simulates without placing.
参数是否必填描述
amount
下单的Mana金额(不含手续费)。
contractId
市场ID。
outcome
YES
(默认)或
NO
limitProb
设置此参数则为限价单,取值范围0.01到0.99(仅支持整数百分比,例如0.01=1%)。
expiresAt
限价单自动取消的时间戳(毫秒)。
expiresMillisAfter
下单后多久自动取消(毫秒)。
dryRun
设为
true
时仅模拟下单,不会实际执行。

Multi-Bet Parameters

Multi-Bet参数

ParameterRequiredDescription
contractId
YesMarket ID. Must be
cpmm-multi-1
with
shouldAnswersSumToOne=true
.
answerIds
YesArray of answer IDs (min 2).
amount
YesTotal mana to spend across selected answers.
limitProb
NoPer-leg limit price (0.01–0.99, two decimal places).
expiresAt
NoTimestamp (ms) for auto-cancel of unfilled portions.
参数是否必填描述
contractId
市场ID,必须是
cpmm-multi-1
类型且
shouldAnswersSumToOne=true
answerIds
答案ID数组(至少2个)。
amount
分配给选中答案的总Mana金额。
limitProb
每个答案的限价价格(0.01–0.99,保留两位小数)。
expiresAt
未成交部分自动取消的时间戳(毫秒)。

Comments

评论相关

EndpointMethodAuthDescription
/comment
POSTYesCreate a top-level comment on a market. Params:
contractId
, plus one of
content
(TipTap JSON),
html
, or
markdown
. Fee: M$1.
/comments
GETNoList comments for a market or user. Params:
contractId
,
contractSlug
,
limit
(max 1000),
page
,
userId
,
order
(
likes
/
newest
/
oldest
).
端点方法身份验证描述
/comment
POST在市场中发布顶级评论。参数:
contractId
,以及
content
(TipTap JSON)、
html
markdown
三者之一。费用:M$1。
/comments
GET列出市场或用户的评论。参数:
contractId
contractSlug
limit
(最大1000)、
page
userId
order
likes
/
newest
/
oldest
)。

Bets

交易记录相关

EndpointMethodAuthDescription
/bets
GETNoList bets. Params:
userId
,
username
,
contractId
(can be multiple),
contractSlug
,
limit
(max 1000),
before
/
after
(bet ID cursors),
beforeTime
/
afterTime
(timestamps),
kinds
(
open-limit
),
order
(
asc
/
desc
).
端点方法身份验证描述
/bets
GET列出交易记录。参数:
userId
username
contractId
(可多个)、
contractSlug
limit
(最大1000)、
before
/
after
(交易ID游标)、
beforeTime
/
afterTime
(时间戳)、
kinds
open-limit
)、
order
asc
/
desc
)。

Bet Type

Bet类型

Bet {
  id: string
  contractId: string
  userId: string
  amount: number            // mana spent (filled portion for limits)
  orderAmount: number       // original order amount
  shares: number
  outcome: "YES" | "NO"
  probBefore: number
  probAfter: number
  createdTime: number
  fees: {
    creatorFee: number
    platformFee: number
    liquidityFee: number
  }
  isFilled: boolean
  isCancelled: boolean
  loanAmount: number
  limitProb?: number        // present for limit orders
  fills: Fill[]
  answerId?: string         // for multi-choice markets
}

Fill {
  matchedBetId: string | null
  amount: number
  shares: number
  timestamp: number
  fees: { creatorFee: number; platformFee: number; liquidityFee: number }
}
Bet {
  id: string
  contractId: string
  userId: string
  amount: number            // 花费的Mana(限价单为已成交部分)
  orderAmount: number       // 原始订单金额
  shares: number
  outcome: "YES" | "NO"
  probBefore: number
  probAfter: number
  createdTime: number
  fees: {
    creatorFee: number
    platformFee: number
    liquidityFee: number
  }
  isFilled: boolean
  isCancelled: boolean
  loanAmount: number
  limitProb?: number        // 限价单会包含此参数
  fills: Fill[]
  answerId?: string         // 多选项市场会包含此参数
}

Fill {
  matchedBetId: string | null
  amount: number
  shares: number
  timestamp: number
  fees: { creatorFee: number; platformFee: number; liquidityFee: number }
}

Topics (Groups)

主题(Groups)相关

EndpointMethodAuthDescription
/groups
GETNoList public topics, 500 at a time, newest first. Params:
beforeTime
,
availableToUserId
.
/group/[slug]
GETNoGet a topic by slug.
/group/by-id/[id]
GETNoGet a topic by ID.
端点方法身份验证描述
/groups
GET列出公开主题,每次最多500个,按创建时间降序。参数:
beforeTime
availableToUserId
/group/[slug]
GET通过slug获取主题信息。
/group/by-id/[id]
GET通过ID获取主题信息。

Mana Transfers

Mana转账相关

EndpointMethodAuthDescription
/managram
POSTYesSend mana to other users. Params:
toIds
(array of user IDs),
amount
(>= 10, sent to each),
message
(optional).
端点方法身份验证描述
/managram
POST向其他用户发送Mana。参数:
toIds
(用户ID数组)、
amount
(>=10,每个用户收到该金额)、
message
(可选)。

Transactions

交易记录(Transactions)相关

EndpointMethodAuthDescription
/txns
GETNoList transactions, newest first. Params:
token
(
CASH
/
MANA
),
offset
,
limit
(max 100),
before
/
after
(timestamps),
toId
,
fromId
,
category
.
端点方法身份验证描述
/txns
GET列出交易记录,按时间降序。参数:
token
CASH
/
MANA
)、
offset
limit
(最大100)、
before
/
after
(时间戳)、
toId
fromId
category

Leagues

排行榜(Leagues)相关

EndpointMethodAuthDescription
/leagues
GETNoGet league standings. Params:
userId
,
season
(number),
cohort
(string).

端点方法身份验证描述
/leagues
GET获取排行榜排名。参数:
userId
season
(数字)、
cohort
(字符串)。

Market Types

市场类型

outcomeType
mechanism
Description
BINARY
cpmm-1
Yes/No market with a single probability (0–1). Most common type.
MULTIPLE_CHOICE
cpmm-multi-1
Multiple answers, each with its own probability. Can be dependent (sum to 100%) or independent.
FREE_RESPONSE
dpm-2
Legacy. Anyone can add answers. Uses DPM mechanism.
PSEUDO_NUMERIC
cpmm-1
Maps probability to a numeric range [min, max]. Can be linear or log scale.
BOUNTIED_QUESTION
No trading. Creator distributes bounty to best comments.
POLL
No trading. Users vote on options.

outcomeType
mechanism
描述
BINARY
cpmm-1
是/否类型的市场,单个概率值(0–1),最常见的市场类型。
MULTIPLE_CHOICE
cpmm-multi-1
多选项市场,每个答案有独立的概率。分为依赖型(概率总和为100%)和独立型。
FREE_RESPONSE
dpm-2
遗留类型,任何人都可添加答案,使用DPM机制。
PSEUDO_NUMERIC
cpmm-1
将概率映射到数值区间[min, max],支持线性或对数刻度。
BOUNTIED_QUESTION
非交易类市场,创建者向最佳评论发放悬赏。
POLL
非交易类市场,用户仅能投票。

LiteMarket Type

LiteMarket类型

LiteMarket {
  id: string
  creatorId: string
  creatorUsername: string
  creatorName: string
  creatorAvatarUrl?: string
  createdTime: number
  closeTime?: number
  question: string
  url: string                      // always points to manifold.markets
  outcomeType: string
  mechanism: string
  probability: number
  pool: { [outcome: string]: number }
  p?: number                       // CPMM probability constant
  totalLiquidity?: number          // CPMM only
  value?: number                   // PSEUDO_NUMERIC only
  min?: number                     // PSEUDO_NUMERIC only
  max?: number                     // PSEUDO_NUMERIC only
  isLogScale?: boolean             // PSEUDO_NUMERIC only
  volume: number
  volume24Hours: number
  isResolved: boolean
  resolutionTime?: number
  resolution?: string
  resolutionProbability?: number   // for MKT resolution
  uniqueBettorCount: number
  lastUpdatedTime?: number
  lastBetTime?: number
  token?: "MANA" | "CASH"
  siblingContractId?: string       // toggle between mana/cash version
}
LiteMarket {
  id: string
  creatorId: string
  creatorUsername: string
  creatorName: string
  creatorAvatarUrl?: string
  createdTime: number
  closeTime?: number
  question: string
  url: string                      // 始终指向manifold.markets
  outcomeType: string
  mechanism: string
  probability: number
  pool: { [outcome: string]: number }
  p?: number                       // CPMM概率常数
  totalLiquidity?: number          // 仅CPMM市场有此参数
  value?: number                   // 仅PSEUDO_NUMERIC市场有此参数
  min?: number                     // 仅PSEUDO_NUMERIC市场有此参数
  max?: number                     // 仅PSEUDO_NUMERIC市场有此参数
  isLogScale?: boolean             // 仅PSEUDO_NUMERIC市场有此参数
  volume: number
  volume24Hours: number
  isResolved: boolean
  resolutionTime?: number
  resolution?: string
  resolutionProbability?: number   // 结算为MKT时的概率
  uniqueBettorCount: number
  lastUpdatedTime?: number
  lastBetTime?: number
  token?: "MANA" | "CASH"
  siblingContractId?: string       // 在Mana/现金版本间切换
}

FullMarket Type

FullMarket类型

FullMarket = LiteMarket & {
  answers?: Answer[]                          // multi markets only
  shouldAnswersSumToOne?: boolean             // multi markets only
  addAnswersMode?: "ANYONE" | "ONLY_CREATOR" | "DISABLED"
  options?: { text: string; votes: number }[] // poll only
  totalBounty?: number                        // bounty only
  bountyLeft?: number                         // bounty only
  description: JSONContent                    // TipTap rich text
  textDescription: string                     // plain text
  coverImageUrl?: string
  groupSlugs?: string[]                       // topic tags
}

FullMarket = LiteMarket & {
  answers?: Answer[]                          // 仅多选项市场有此参数
  shouldAnswersSumToOne?: boolean             // 仅多选项市场有此参数
  addAnswersMode?: "ANYONE" | "ONLY_CREATOR" | "DISABLED"
  options?: { text: string; votes: number }[] // 仅投票市场有此参数
  totalBounty?: number                        // 仅悬赏市场有此参数
  bountyLeft?: number                         // 仅悬赏市场有此参数
  description: JSONContent                    // TipTap富文本
  textDescription: string                     // 纯文本描述
  coverImageUrl?: string
  groupSlugs?: string[]                       // 主题标签
}

WebSocket API

WebSocket API

Manifold provides a real-time WebSocket server for subscribing to live updates.
Manifold提供实时WebSocket服务器,用于订阅市场的实时更新。

Connection

连接地址

wss://api.manifold.markets/ws         (production)
wss://api.dev.manifold.markets/ws     (dev)
No authentication is required to connect. Authentication is optional (for user-specific topics).
wss://api.manifold.markets/ws         (生产环境)
wss://api.dev.manifold.markets/ws     (开发环境)
连接无需身份验证,身份验证为可选(用于订阅用户专属主题)。

Message Format

消息格式

All messages are JSON. Client messages must include:
  • type
    :
    identify
    ,
    subscribe
    ,
    unsubscribe
    , or
    ping
    .
  • txid
    : A unique number identifying the message.
The server acknowledges each message:
{ "type": "ack", "txid": 123, "success": true }
所有消息均为JSON格式。客户端消息必须包含:
  • type
    :
    identify
    subscribe
    unsubscribe
    ping
  • txid
    : 唯一标识该消息的数字。
服务器会确认每条消息:
{ "type": "ack", "txid": 123, "success": true }

Subscribing to Topics

订阅主题

Send a subscribe message:
{
  "type": "subscribe",
  "txid": 1,
  "topics": ["global/new-bet", "contract/[marketId]"]
}
发送订阅消息:
{
  "type": "subscribe",
  "txid": 1,
  "topics": ["global/new-bet", "contract/[marketId]"]
}

Available Topics

可用主题

Global Topics

全局主题

TopicDescription
global/new-bet
All new bets across all markets.
global/new-contract
All new markets being created.
global/new-comment
All new comments across all markets.
global/new-subsidy
All new liquidity subsidies.
global/updated-contract
Updates to any public market.
主题描述
global/new-bet
所有市场的新交易记录。
global/new-contract
所有新创建的市场。
global/new-comment
所有市场的新评论。
global/new-subsidy
所有新的流动性补贴。
global/updated-contract
所有公开市场的更新。

Per-Market Topics (replace
[marketId]
with actual ID)

单市场主题(将
[marketId]
替换为实际ID)

TopicDescription
contract/[marketId]
General market updates.
contract/[marketId]/new-bet
New bets on this market.
contract/[marketId]/new-comment
New comments on this market.
contract/[marketId]/new-subsidy
New liquidity subsidies.
contract/[marketId]/new-answer
New answers added (multi-choice).
contract/[marketId]/updated-answers
Updates to existing answers.
contract/[marketId]/orders
Limit order updates.
contract/[marketId]/chart-annotation
Chart annotations.
contract/[marketId]/user-metrics/[userId]
User position updates in this market.
主题描述
contract/[marketId]
市场的通用更新。
contract/[marketId]/new-bet
该市场的新交易记录。
contract/[marketId]/new-comment
该市场的新评论。
contract/[marketId]/new-subsidy
该市场的新流动性补贴。
contract/[marketId]/new-answer
新增的答案(多选项市场)。
contract/[marketId]/updated-answers
现有答案的更新。
contract/[marketId]/orders
限价单的更新。
contract/[marketId]/chart-annotation
图表注释的更新。
contract/[marketId]/user-metrics/[userId]
用户在该市场的持仓更新。

Other Topics

其他主题

TopicDescription
user/[userId]
Updates to a user's public info.
answer/[answerId]/update
Updates to a specific answer.
tv_schedule
Updates to the TV schedule.
主题描述
user/[userId]
用户公开信息的更新。
answer/[answerId]/update
特定答案的更新。
tv_schedule
TV日程的更新。

Keep-Alive

保持连接

Send periodic pings (every 30–60 seconds) to keep the connection alive. If no ping is received for 60 seconds, the server terminates the connection.
{ "type": "ping", "txid": 42 }
需定期发送ping消息(每30–60秒一次)以保持连接。如果60秒内未收到ping消息,服务器会终止连接。
{ "type": "ping", "txid": 42 }

Broadcast Messages

广播消息

The server sends updates as broadcast messages:
{
  "type": "broadcast",
  "topic": "global/new-bet",
  "data": { ... }
}

服务器会通过广播消息发送更新:
{
  "type": "broadcast",
  "topic": "global/new-bet",
  "data": { ... }
}

Common Patterns

常见使用示例

List Recent Markets

列出最近的市场

bash
curl -s "https://api.manifold.markets/v0/markets?limit=5" | jq '.[].question'
bash
curl -s "https://api.manifold.markets/v0/markets?limit=5" | jq '.[].question'

Get a Single Market by ID

通过ID获取单个市场

bash
curl -s "https://api.manifold.markets/v0/market/3zspH9sSzMlbFQLn9GKR" | jq '{question, probability, volume, isResolved}'
bash
curl -s "https://api.manifold.markets/v0/market/3zspH9sSzMlbFQLn9GKR" | jq '{question, probability, volume, isResolved}'

Get a Market by Slug

通过Slug获取市场

bash
curl -s "https://api.manifold.markets/v0/slug/will-carrick-flynn-win-the-general" | jq '{question, probability}'
bash
curl -s "https://api.manifold.markets/v0/slug/will-carrick-flynn-win-the-general" | jq '{question, probability}'

Search for Open Binary Markets

搜索开放的二元市场

bash
curl -s "https://api.manifold.markets/v0/search-markets?term=AI&sort=liquidity&filter=open&contractType=BINARY&limit=10" | jq '.[].question'
bash
curl -s "https://api.manifold.markets/v0/search-markets?term=AI&sort=liquidity&filter=open&contractType=BINARY&limit=10" | jq '.[].question'

Get Current Probability

获取当前概率

bash
curl -s "https://api.manifold.markets/v0/market/9t61v9e7x4/prob" | jq '.'
bash
curl -s "https://api.manifold.markets/v0/market/9t61v9e7x4/prob" | jq '.'

Get Batch Probabilities

批量获取概率

bash
curl -s "https://api.manifold.markets/v0/market-probs?ids=9t61v9e7x4&ids=ZNlNdzz690" | jq '.'
bash
curl -s "https://api.manifold.markets/v0/market-probs?ids=9t61v9e7x4&ids=ZNlNdzz690" | jq '.'

Place a YES Bet

下单YES交易

bash
curl -X POST "https://api.manifold.markets/v0/bet" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10, "contractId": "MARKET_ID", "outcome": "YES"}'
bash
curl -X POST "https://api.manifold.markets/v0/bet" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10, "contractId": "MARKET_ID", "outcome": "YES"}'

Place a Limit Order

下单限价单

bash
curl -X POST "https://api.manifold.markets/v0/bet" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 100,
    "contractId": "MARKET_ID",
    "outcome": "YES",
    "limitProb": 0.40,
    "expiresMillisAfter": 86400000
  }'
bash
curl -X POST "https://api.manifold.markets/v0/bet" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 100,
    "contractId": "MARKET_ID",
    "outcome": "YES",
    "limitProb": 0.40,
    "expiresMillisAfter": 86400000
  }'

Sell All Shares in a Market

卖出市场中的所有份额

bash
curl -X POST "https://api.manifold.markets/v0/market/MARKET_ID/sell" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcome": "YES"}'
bash
curl -X POST "https://api.manifold.markets/v0/market/MARKET_ID/sell" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcome": "YES"}'

Cancel a Limit Order

取消限价单

bash
curl -X POST "https://api.manifold.markets/v0/bet/cancel/BET_ID" \
  -H "Authorization: Key YOUR_API_KEY"
bash
curl -X POST "https://api.manifold.markets/v0/bet/cancel/BET_ID" \
  -H "Authorization: Key YOUR_API_KEY"

Create a Binary Market

创建二元市场

bash
curl -X POST "https://api.manifold.markets/v0/market" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcomeType": "BINARY",
    "question": "Will it rain in SF tomorrow?",
    "descriptionMarkdown": "Resolves YES if measurable rainfall is recorded at SFO weather station.",
    "initialProb": 30,
    "closeTime": 1735689600000
  }'
bash
curl -X POST "https://api.manifold.markets/v0/market" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcomeType": "BINARY",
    "question": "旧金山明天会下雨吗?",
    "descriptionMarkdown": "若SFO气象站记录到可测量的降雨量,则结算为YES。",
    "initialProb": 30,
    "closeTime": 1735689600000
  }'

Create a Multiple Choice Market

创建多选项市场

bash
curl -X POST "https://api.manifold.markets/v0/market" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcomeType": "MULTIPLE_CHOICE",
    "question": "Who will win the award?",
    "answers": ["Alice", "Bob", "Charlie"],
    "shouldAnswersSumToOne": true,
    "addAnswersMode": "ONLY_CREATOR"
  }'
bash
curl -X POST "https://api.manifold.markets/v0/market" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcomeType": "MULTIPLE_CHOICE",
    "question": "谁会获得该奖项?",
    "answers": ["Alice", "Bob", "Charlie"],
    "shouldAnswersSumToOne": true,
    "addAnswersMode": "ONLY_CREATOR"
  }'

Resolve a Binary Market

结算二元市场

bash
curl -X POST "https://api.manifold.markets/v0/market/MARKET_ID/resolve" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcome": "YES"}'
bash
curl -X POST "https://api.manifold.markets/v0/market/MARKET_ID/resolve" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcome": "YES"}'

Get Your Portfolio

获取个人投资组合

bash
curl -s "https://api.manifold.markets/v0/get-user-portfolio?userId=YOUR_USER_ID" | jq '.'
bash
curl -s "https://api.manifold.markets/v0/get-user-portfolio?userId=YOUR_USER_ID" | jq '.'

Get Top Positions on a Market

获取市场中的顶级持仓用户

bash
curl -s "https://api.manifold.markets/v0/market/MARKET_ID/positions?top=5&order=profit" | jq '.[].userName'
bash
curl -s "https://api.manifold.markets/v0/market/MARKET_ID/positions?top=5&order=profit" | jq '.[].userName'

Paginate Through All Markets (by newest)

分页获取所有市场(按最新创建)

bash
undefined
bash
undefined

Page 1

第一页

Page 2: use createdTime of last result

第二页:使用上一页最后一条结果的createdTime

BEFORE_TIME=$(jq '.[-1].createdTime' page1.json) curl -s "https://api.manifold.markets/v0/search-markets?sort=newest&limit=100&beforeTime=$BEFORE_TIME" > page2.json
undefined
BEFORE_TIME=$(jq '.[-1].createdTime' page1.json) curl -s "https://api.manifold.markets/v0/search-markets?sort=newest&limit=100&beforeTime=$BEFORE_TIME" > page2.json
undefined

Paginate Through Bets

分页获取交易记录

bash
undefined
bash
undefined

First page

第一页

Next page: use ID of last bet

下一页:使用上一页最后一条交易记录的ID

BEFORE=$(jq -r '.[-1].id' bets1.json) curl -s "https://api.manifold.markets/v0/bets?contractId=MARKET_ID&limit=100&before=$BEFORE" > bets2.json
undefined
BEFORE=$(jq -r '.[-1].id' bets1.json) curl -s "https://api.manifold.markets/v0/bets?contractId=MARKET_ID&limit=100&before=$BEFORE" > bets2.json
undefined

Send Mana to Users

向用户发送Mana

bash
curl -X POST "https://api.manifold.markets/v0/managram" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"toIds": ["USER_ID_1", "USER_ID_2"], "amount": 100, "message": "Thanks!"}'
bash
curl -X POST "https://api.manifold.markets/v0/managram" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"toIds": ["USER_ID_1", "USER_ID_2"], "amount": 100, "message": "谢谢!"}'

Post a Comment

发布评论

bash
curl -X POST "https://api.manifold.markets/v0/comment" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contractId": "MARKET_ID", "markdown": "Great question! I think YES is undervalued."}'
bash
curl -X POST "https://api.manifold.markets/v0/comment" \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contractId": "MARKET_ID", "markdown": "很棒的问题!我认为YES被低估了。"}'

WebSocket Subscription (Node.js)

WebSocket订阅示例(Node.js)

javascript
const ws = new WebSocket("wss://api.manifold.markets/ws");
let txid = 0;

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    txid: txid++,
    topics: ["global/new-bet"]
  }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.type === "broadcast") {
    console.log("New bet:", msg.data);
  }
};

// Keep-alive ping every 30 seconds
setInterval(() => {
  ws.send(JSON.stringify({ type: "ping", txid: txid++ }));
}, 30000);

javascript
const ws = new WebSocket("wss://api.manifold.markets/ws");
let txid = 0;

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    txid: txid++,
    topics: ["global/new-bet"]
  }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.type === "broadcast") {
    console.log("新交易:", msg.data);
  }
};

// 每30秒发送一次ping以保持连接
setInterval(() => {
  ws.send(JSON.stringify({ type: "ping", txid: txid++ }));
}, 30000);

Usage Tips

使用技巧

  • All timestamps are UNIX milliseconds (JavaScript
    Date.now()
    style), not seconds.
  • Never hardcode API keys — use environment variables or secure key storage.
  • Market URLs always point to
    https://manifold.markets
    regardless of which API instance you're using. The username in the URL path doesn't need to be correct (e.g.,
    manifold.markets/anyone/market-slug
    works).
  • GET parameters go in the query string. POST/PUT parameters go in the JSON body.
  • Limit orders with
    limitProb
    crossing the current market price will partially fill immediately. Any unfilled remainder stays as a resting limit order.
  • limitProb
    precision
    : Only whole percentage points (two decimal places, e.g.,
    0.01
    ,
    0.50
    ,
    0.99
    ).
  • Multi-choice markets come in two flavors: dependent (
    shouldAnswersSumToOne=true
    , probabilities sum to 100%) and independent (each answer is effectively a separate binary market).
  • Combine REST + WebSocket for best results: use REST for initial state, WebSocket for real-time deltas.
  • Paginate responsibly: For
    /search-markets
    with
    sort=newest
    , use
    beforeTime
    for efficient deep pagination. For
    /bets
    and
    /markets
    , use cursor-based pagination with
    before
    /
    after
    .
  • Market token type matters: check the
    token
    field (
    MANA
    or
    CASH
    ) to know if a market uses play-money or prize-cash.
  • Dry run bets by passing
    dryRun: true
    to simulate without placing.
  • Description formats: You can provide market descriptions as plain text (
    description
    ), HTML (
    descriptionHtml
    ), Markdown (
    descriptionMarkdown
    ), or TipTap JSON (
    descriptionJson
    ). Only provide one.

  • 所有时间戳均为UNIX毫秒级(与JavaScript
    Date.now()
    格式一致),而非秒级。
  • 切勿硬编码API密钥——请使用环境变量或安全的密钥存储方式。
  • 市场URL始终指向
    https://manifold.markets
    ,无论你使用哪个API实例。URL路径中的用户名无需正确(例如
    manifold.markets/anyone/market-slug
    也可访问)。
  • GET参数需放在查询字符串中,POST/PUT参数需放在JSON请求体中。
  • 限价单
    limitProb
    若与当前市场价格交叉,会立即部分成交,未成交部分会保持挂单状态。
  • limitProb
    精度
    :仅支持整数百分比(两位小数,例如
    0.01
    0.50
    0.99
    )。
  • 多选项市场分为两种类型:依赖型(
    shouldAnswersSumToOne=true
    ,概率总和为100%)和独立型(每个答案相当于独立的二元市场)。
  • 结合REST与WebSocket使用以获得最佳效果:使用REST获取初始状态,使用WebSocket获取实时增量更新。
  • 合理分页:对于
    /search-markets
    sort=newest
    ,使用
    beforeTime
    实现高效深度分页;对于
    /bets
    /markets
    ,使用基于游标的分页方式(
    before
    /
    after
    )。
  • 市场代币类型很重要:请检查
    token
    字段(
    MANA
    CASH
    )以确定市场使用虚拟货币还是奖励现金。
  • 模拟交易可通过传入
    dryRun: true
    实现,不会实际下单。
  • 描述格式:市场描述可提供为纯文本(
    description
    )、HTML(
    descriptionHtml
    )、Markdown(
    descriptionMarkdown
    )或TipTap JSON(
    descriptionJson
    ),仅需提供其中一种。

Error Handling

错误处理

API responses are JSON. Successful requests return HTTP 200 with a JSON result. Error responses (4xx/5xx) return a JSON object with an error message.
StatusMeaning
200Success
400Bad request (invalid parameters)
401Unauthorized (missing or invalid API key)
403Forbidden (insufficient permissions)
404Not found
429Rate limited (500 req/min exceeded)
5xxServer error
Implement retry with exponential backoff for 429 and 5xx responses.

API响应均为JSON格式。成功请求返回HTTP 200及JSON结果。错误响应(4xx/5xx)返回包含错误消息的JSON对象。
状态码含义
200请求成功
400请求参数错误
401未授权(API密钥缺失或无效)
403禁止访问(权限不足)
404资源不存在
429请求频率超限(超过每分钟500次)
5xx服务器内部错误
收到429或5xx响应时,请实现指数退避重试机制。

Internal API

内部API

Manifold has some internal endpoints not part of the official API. These are undocumented and subject to change without notice.
EndpointMethodAuthDescription
/unresolve
POSTYesUnresolve a market. Param:
contractId
.
Note: Internal endpoints are not prefixed with
/v0
.

Manifold有一些未纳入官方API的内部端点,这些端点未被文档化,且可能在无通知的情况下变更。
端点方法身份验证描述
/unresolve
POST撤销市场的结算状态。参数:
contractId
注意:内部端点
/v0/
为前缀。

Versioning

版本控制

The current API version is v0 under
/v0/
. The API is still in alpha. Monitor the official documentation and the Discord for breaking changes.
当前API版本为v0,路径前缀为
/v0/
。API仍处于alpha阶段,请关注官方文档Discord社区以获取重大变更通知。