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

# 轮询更新

> Long-polling endpoint that returns buffered Telegram updates in `getUpdates`-compatible format.

Requires `long_poll_enabled` to be set on the bot. Blocks until new updates are available or `timeout` seconds elapse.

Multiple clients can poll simultaneously. Use `offset` to acknowledge processed updates (same semantics as Telegram's `getUpdates`).




## OpenAPI

````yaml GET /api/updates/poll
openapi: 3.1.0
info:
  title: BotMux API
  description: >
    REST API for BotMux — a multi-bot Telegram management and proxy platform.


    All endpoints return JSON. Errors return `{"error": "message"}` with HTTP
    500 (or 400/401/403/404 where applicable).


    **Authentication**: Use a Bearer API key (`Authorization: Bearer bmx_...`)
    or a session cookie obtained via `/api/auth/login`.
  version: 1.0.0
  contact:
    name: BotMux
servers:
  - url: http://localhost:8080
    description: Local development server
security:
  - BearerAuth: []
  - CookieAuth: []
tags:
  - name: Bots
    description: Bot registration, configuration, and health management
  - name: Chats
    description: Tracked chat management
  - name: Messages
    description: Message retrieval, search, and actions
  - name: Users
    description: Chat member management
  - name: Admins
    description: Chat administrator management
  - name: Tags
    description: User tagging and labels
  - name: Routes
    description: Message routing rules between bots
  - name: Analytics
    description: Chat statistics and metrics
  - name: Audit Log
    description: Administrative action history
  - name: Long Polling
    description: Pull-based update delivery (Telegram-compatible)
  - name: Telegram Proxy
    description: >
      Transparent proxy to api.telegram.org with message capture and method
      interception.


      Several Telegram Bot API methods are intercepted by BotMux instead of
      being forwarded:

      - `setWebhook` — configures the bot's backend URL in BotMux and enables
      proxy mode (auto-registration of unknown tokens requires
      `BOTMUX_ALLOW_AUTO_REGISTER=1`)

      - `deleteWebhook` — clears the backend URL and disables proxy mode

      - `getWebhookInfo` — returns BotMux's internal webhook state

      - `getUpdates` — served from BotMux's internal queue when long polling is
      enabled; returns empty for any other known bot to prevent conflict errors

      - `logOut` — returns success without forwarding (prevents token being
      disabled for 10 minutes)

      - `close` — returns success without forwarding (prevents bot instance
      shutdown on Telegram's side)


      A file download endpoint at `/tgapi/file/bot{TOKEN}/{file_path}` is also
      available as a drop-in replacement for Telegram's file download URL.
paths:
  /api/updates/poll:
    get:
      tags:
        - Long Polling
      summary: Poll for updates
      description: >
        Long-polling endpoint that returns buffered Telegram updates in
        `getUpdates`-compatible format.


        Requires `long_poll_enabled` to be set on the bot. Blocks until new
        updates are available or `timeout` seconds elapse.


        Multiple clients can poll simultaneously. Use `offset` to acknowledge
        processed updates (same semantics as Telegram's `getUpdates`).
      operationId: pollUpdates
      parameters:
        - name: bot_id
          in: query
          required: true
          schema:
            type: integer
          description: Bot ID to poll updates for
        - name: offset
          in: query
          schema:
            type: integer
            default: 0
          description: >-
            Acknowledge updates with update_id < offset (Telegram getUpdates
            semantics)
        - name: limit
          in: query
          schema:
            type: integer
            default: 100
            maximum: 100
          description: Maximum number of updates to return
        - name: timeout
          in: query
          schema:
            type: integer
            default: 30
            maximum: 60
          description: Seconds to wait for updates before returning empty result
      responses:
        '200':
          description: Telegram-compatible getUpdates response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetUpdatesResponse'
              example:
                ok: true
                result:
                  - update_id: 100000001
                    message:
                      message_id: 42
                      text: Hello
        '400':
          description: Invalid parameters or long_poll_enabled not set for bot
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GetUpdatesResponse:
      type: object
      description: Telegram-compatible getUpdates response
      properties:
        ok:
          type: boolean
          example: true
        result:
          type: array
          items:
            $ref: '#/components/schemas/TelegramUpdate'
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
      required:
        - error
      example:
        error: bot not found
    TelegramUpdate:
      type: object
      description: Raw Telegram Update object as defined in the Telegram Bot API
      properties:
        update_id:
          type: integer
        message:
          type: object
          description: Telegram Message object
        edited_message:
          type: object
        channel_post:
          type: object
        callback_query:
          type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key with `bmx_` prefix. Obtain via `/api/auth/api-keys`.
    CookieAuth:
      type: apiKey
      in: cookie
      name: session
      description: Session cookie obtained after login via `/api/auth/login`.

````