> ## Documentation Index
> Fetch the complete documentation index at: https://docs.55-tech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ABP 快速入门 - 下您的第一注

> 通过 ABP API 下您第一注的分步指南。从账户设置到下单、跟踪和结算。

## 步骤1：列出您的账户

检查为您的API密钥配置了哪些博彩公司账户：

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  https://v2.55-tech.com/accounts
```

响应包括每个账户的博彩公司、余额、优先级、投注限额和货币：

```json theme={null}
[
  {
    "bookmaker": "pinnacle",
    "username": "pinnacle_main",
    "client": "your-client",
    "password": "***",
    "balance": 5000.0,
    "active": true,
    "priority": 10,
    "maxStake": 1000.0,
    "minStake": 5.0,
    "currencyId": "USD",
    "verifyBetslip": false,
    "meta": {},
    "createdAt": "2026-01-01T00:00:00Z",
    "updatedAt": "2026-02-01T12:00:00Z",
    "multiLimitAllowed": true,
    "currencyInfo": { "currency": "USD", "currencyValue": 1, "updatedAt": "2026-02-07T17:29:32+00:00" }
  }
]
```

## 步骤2：获取投注单

下注前，获取当前赔率和限额。需要 `fixtureId`、`outcomeId` 和 `playerId`：

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -H "x-api-key: YOUR_API_KEY" \
      "https://v2.55-tech.com/betslip?fixtureId=id1000004461512432&outcomeId=103&playerId=0"
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    resp = requests.get(
        "https://v2.55-tech.com/betslip",
        headers={"x-api-key": "YOUR_API_KEY"},
        params={"fixtureId": "id1000004461512432", "outcomeId": 103, "playerId": 0},
    )
    print(resp.json()["odds"])
    ```
  </Tab>
</Tabs>

投注单返回每个有此市场的博彩公司的实时赔率，包含赛事和结果元数据：

```json theme={null}
{
  "fixtureId": "id1000004461512432",
  "outcomeId": 103,
  "playerId": 0,
  "client": "your-client",
  "fixtureInfo": {
    "sport": { "sportId": 10, "sportName": "Soccer" },
    "tournament": { "tournamentName": "Serie A", "categoryName": "Italy" },
    "participants": {
      "participant1Name": "AS Roma",
      "participant2Name": "Cagliari Calcio"
    }
  },
  "outcomeInfo": {
    "marketName": "Full Time Result",
    "outcomeName": "2"
  },
  "odds": {
    "pinnacle": {
      "id1000004461512432:pinnacle:103:0": {
        "price": 1.98,
        "limit": 15000,
        "limitMin": 5,
        "limitCurrency": "USD",
        "limitUsd": 15000,
        "limitMinUsd": 5,
        "active": true,
        "account": "pinnacle_main",
        "currencyInfo": { "currency": "USD", "currencyValue": 1, "updatedAt": "2026-02-07T17:29:32+00:00" }
      }
    },
    "sharpbet": {
      "id1000004461512432:sharpbet:103:0": {
        "price": 2.0,
        "limit": 751.34,
        "limitMin": 1,
        "limitCurrency": "EUR",
        "limitUsd": 886.13,
        "limitMinUsd": 1.18,
        "active": true,
        "account": "sharpbet_user",
        "currencyInfo": { "currency": "EUR", "currencyValue": 0.84788876, "updatedAt": "2026-02-07T17:29:32+00:00" }
      }
    }
  }
}
```

<Note>
  使用 [OddsPapi API](https://docs.oddspapi.io/) 查找赛事ID和结果ID。ABP 直接使用 OddsPapi 标识符。
</Note>

## 步骤3：下单

下一个带最低价格保护的投注订单。每个订单需要唯一的 `requestUuid` 以确保幂等性：

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST \
      -H "x-api-key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "orders": [
          {
            "requestUuid": "eb45b192-317b-42d5-9f65-af497b9fa8c1",
            "fixtureId": "id1000004461512432",
            "outcomeId": 103,
            "playerId": 0,
            "orderStake": 10.0,
            "orderPrice": 1.95,
            "userRef": "my-strategy-1",
            "testOrder": false
          }
        ]
      }' \
      https://v2.55-tech.com/place-orders
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import uuid, requests

    resp = requests.post(
        "https://v2.55-tech.com/place-orders",
        headers={"x-api-key": "YOUR_API_KEY"},
        json={"orders": [{
            "requestUuid": str(uuid.uuid4()),
            "fixtureId": "id1000004461512432",
            "outcomeId": 103,
            "playerId": 0,
            "orderStake": 10.0,
            "orderPrice": 1.95,
            "userRef": "my-strategy-1",
            "testOrder": False,
        }]},
    )
    print(resp.json())
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    import { randomUUID } from "crypto";

    const resp = await fetch("https://v2.55-tech.com/place-orders", {
      method: "POST",
      headers: {
        "x-api-key": "YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        orders: [{
          requestUuid: randomUUID(),
          fixtureId: "id1000004461512432",
          outcomeId: 103,
          playerId: 0,
          orderStake: 10.0,
          orderPrice: 1.95,
          userRef: "my-strategy-1",
          testOrder: false,
        }],
      }),
    });
    console.log(await resp.json());
    ```
  </Tab>
</Tabs>

**关键字段：**

| 字段                   | 必填 | 描述                                            |
| -------------------- | -- | --------------------------------------------- |
| `requestUuid`        | 是  | 用于幂等性的唯一UUID（30分钟内的重复项会被跳过；仅当每个订单都是重复时才返回409） |
| `fixtureId`          | 是  | OddsPapi 赛事ID                                 |
| `outcomeId`          | 是  | 市场结果（例如 103 = 客胜）                             |
| `playerId`           | 是  | 非球员盘设为 `0`                                    |
| `orderStake`         | 是  | 总投注金额                                         |
| `orderPrice`         | 是  | 最低可接受十进制赔率                                    |
| `userRef`            | 是  | 用于分组相关订单的引用                                   |
| `testOrder`          | 是  | 仅验证不实际下注（实际投注设为 `false`）                      |
| `bookmakers`         | 否  | 逗号分隔的目标博彩公司标识（省略则自动选择）                        |
| `orderCurrency`      | 否  | 货币代码（默认：`USD`）                                |
| `acceptBetterOdds`   | 否  | 接受优于 `orderPrice` 的赔率（默认：`true`）              |
| `acceptPartialStake` | 否  | 允许部分成交（默认：`true`）                             |
| `back`               | 否  | 买入注（`true`）或卖出注（`false`）（默认：`true`）           |
| `expiresAt`          | 否  | ISO 8601 过期时间（默认：从现在起5秒）                      |
| `meta`               | 否  | 自定义元数据对象（存储但不发送给博彩公司）                         |

**响应：**

```json theme={null}
{
  "status": "accepted",
  "acceptedOrders": [
    {
      "orderId": 327,
      "requestUuid": "eb45b192-317b-42d5-9f65-af497b9fa8c1",
      "orderStatus": "FILLED",
      "fixtureId": "id1000004461512432",
      "outcomeId": 103,
      "orderStake": 10.0,
      "orderPrice": 1.95,
      "filledStake": 10.0,
      "bets": [
        {
          "betId": 73,
          "bookmaker": "pinnacle",
          "placedPrice": 1.98,
          "placedStake": 10.0,
          "betStatus": "CONFIRMED"
        }
      ]
    }
  ],
  "declinedOrders": []
}
```

验证失败的订单会出现在 `declinedOrders` 中，并包含 `declineReason`：

```json theme={null}
{
  "status": "declined",
  "acceptedOrders": [],
  "declinedOrders": [
    {
      "requestUuid": "fb5f2dd9-c855-4ba9-8ef9-4c2278ca2f1d",
      "fixtureId": "id1000004461512432",
      "outcomeId": 103,
      "declineReason": "Order stake 100.00 USD exceeds available limit 50.00 USD"
    }
  ]
}
```

<Tip>
  **无需真实下注即可测试。**设置 `testOrder: true` 会走完整的校验与路由流程（额度、价格检查、账户选择），但**不会**向博彩公司发送投注。这是上线前确认你的请求体与 ID 正确的最快方式。
</Tip>

## 步骤4：跟踪您的订单

按 `userRef`、`orderIds` 或 `requestUuids` 查询订单（至少需要一个过滤条件）：

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  "https://v2.55-tech.com/orders?userRef=my-strategy-1"
```

查看特定订单的单个投注：

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  "https://v2.55-tech.com/bets?orderIds=327"
```

每个投注包括博彩公司、下注价格、下注金额、投注状态和结算状态：

```json theme={null}
{
  "status": "success",
  "bets": [
    {
      "betId": 73,
      "orderId": 327,
      "bookmaker": "pinnacle",
      "bookmakerBetId": "3332684214",
      "placedStake": 10.0,
      "placedPrice": 1.98,
      "placedCurrency": "USD",
      "betStatus": "CONFIRMED",
      "settlementStatus": "UNSETTLED",
      "account": "pinnacle_main",
      "userRef": "my-strategy-1"
    }
  ],
  "count": 1,
  "hasMore": false,
  "nextCursor": null
}
```

## 步骤5：查看持仓和盈亏

查看您的汇总敞口（默认按博彩公司分组）：

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  https://v2.55-tech.com/positions
```

```json theme={null}
{
  "status": "success",
  "groupBy": "bookmaker",
  "positions": [
    { "bookmaker": "pinnacle", "openBets": 5, "totalStake": 250.0, "avgPrice": 1.92 }
  ],
  "count": 1,
  "totalStake": 250.0,
  "totalOpenBets": 5
}
```

查看盈亏：

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  https://v2.55-tech.com/pnl
```

```json theme={null}
{
  "status": "success",
  "groupBy": "bookmaker",
  "pnl": [
    { "bookmaker": "pinnacle", "settledBets": 42, "wins": 23, "losses": 17, "netPnl": 250.0, "winRate": 54.8 }
  ],
  "count": 1,
  "totalNetPnl": 250.0,
  "totalStaked": 2100.0,
  "totalSettledBets": 42
}
```

## 下一步

<Columns cols={2}>
  <Card title="核心概念" icon="lightbulb" href="/zh/abp-api/concepts">
    订单与投注、标识符、幂等性与生命周期。
  </Card>

  <Card title="订单下注" icon="bullseye-arrow" href="/zh/abp-api/order-placement">
    成交、定价与额度级联。
  </Card>

  <Card title="WebSocket 更新" icon="bolt" href="/zh/abp-api/websocket">
    实时订单、投注与结算更新。
  </Card>

  <Card title="实战范例" icon="book-open" href="/zh/abp-api/order-placement#实战范例">
    常见集成的可复制模式。
  </Card>
</Columns>
