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

# 搜索活动

<div className="inline-flex items-center gap-2 px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg">
  <span className="text-base">🪙</span>
  <span className="text-sm font-medium text-yellow-900 dark:text-yellow-100"><span className="font-semibold">4 credits</span><span className="text-yellow-700 dark:text-yellow-300 ml-1">每次请求</span></span>
</div>

## 复制给 AI

<div className="my-6 rounded-xl border border-gray-200 bg-gray-50 p-5 dark:border-gray-800 dark:bg-gray-900/40">
  <div className="min-w-0">
    <p className="text-base font-semibold text-gray-900 dark:text-gray-100">🤖 为什么还要自己写代码？</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">让 AI 来处理重复工作。点击按钮即可复制一段整理好的提示词，用于 ChatGPT、Claude 或你常用的 AI 助手。</p>
  </div>

  <div className="mt-4">
    <button
      type="button"
      className="inline-flex items-center gap-2 rounded-md border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-800 hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-100 dark:hover:bg-emerald-900/50"
      onClick={() => navigator.clipboard.writeText(`我需要调用下面的 KeyAPI 接口，请根据提供的接口信息生成一份完整、可直接运行的 Python 示例代码。

## 接口信息

Endpoint: GET https://api.keyapi.ai/v1/facebook/search_events
摘要: 搜索活动

必需请求头:
- Authorization: Bearer <YOUR_API_KEY>

参数:
- query (必填): 搜索关键词. 示例: facebook
- cursor (可选): 分页游标，用于获取下一页数据.
- location_uid (可选): 地点 UID.
- start_date (可选): 开始日期，格式为 yyyy-mm-dd.
- end_date (可选): 结束日期，格式为 yyyy-mm-dd.

## 代码要求

- 使用 Python \`requests\` 库
- 提供完整、可直接运行的示例
- 处理 HTTP 请求异常、超时以及非 2xx 响应
- 处理 JSON 解析异常
- 示例参数优先使用接口信息中提供的 Example
- 保持代码简单，避免不必要的封装和复杂设计`)}
    >
      <span>✨</span>
      <span>复制给 AI</span>
    </button>
  </div>
</div>


## OpenAPI

````yaml /zh/facebook.zh.openapi.json get /v1/facebook/search_events
openapi: 3.0.1
info:
  title: KeyAPI Facebook API 中文文档
  description: KeyAPI Facebook API 的中文参考文档，包含接口用途、参数说明、响应状态和示例结构。
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production-KeyAPI
security:
  - JWT Bearer: []
tags:
  - name: 公共主页
  - name: 个人主页
  - name: 群组
  - name: 帖子与评论
  - name: 广告库
  - name: 活动
  - name: 搜索
  - name: Marketplace
  - name: 游戏
paths:
  /v1/facebook/search_events:
    get:
      tags:
        - 搜索
      summary: 搜索活动
      parameters:
        - name: query
          in: query
          description: 搜索关键词。
          required: true
          example: facebook
          schema:
            type: string
            example: beer
        - name: cursor
          in: query
          description: 分页游标，用于获取下一页数据。
          required: false
          schema:
            type: string
        - name: location_uid
          in: query
          description: 地点 UID。
          required: false
          schema:
            type: string
        - name: start_date
          in: query
          description: 开始日期，格式为 yyyy-mm-dd。
          required: false
          schema:
            type: string
        - name: end_date
          in: query
          description: 结束日期，格式为 yyyy-mm-dd。
          required: false
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 0
                message: success
                data:
                  results:
                    - type: search_event
                      event_id: '490113270645875'
                      title: >-
                        The FACEBOOK Team || Like, Comment, Share & Follower
                        Support
                      url: https://www.facebook.com/events/490113270645875/
                    - type: search_event
                      event_id: '1163376062227840'
                      title: '2026'
                      url: https://www.facebook.com/events/1163376062227840/
                    - type: search_event
                      event_id: '1886634488612811'
                      title: 'Facebook '
                      url: https://www.facebook.com/events/1886634488612811/
                    - type: search_event
                      event_id: '4557262567890380'
                      title: Facebook viral photo challenge
                      url: https://www.facebook.com/events/4557262567890380/
                    - type: search_event
                      event_id: '1058335573671103'
                      title: 'happy ଜନ୍ମାଷ୍ଟମୀ #facebook #reels'
                      url: https://www.facebook.com/events/1058335573671103/
                    - type: search_event
                      event_id: '980320284704948'
                      title: 'jyoti Vishwakarma '
                      url: https://www.facebook.com/events/980320284704948/
                    - type: search_event
                      event_id: '1473878351119059'
                      title: 'Vikash '
                      url: https://www.facebook.com/events/1473878351119059/
                    - type: search_event
                      event_id: '1387965729847863'
                      title: live
                      url: https://www.facebook.com/events/1387965729847863/
                  cursor: >-
                    {"page_number": 0, "flow_cursors_serialized":
                    {"INTERNAL_DEBUG_MODULE": "{}", "SEARCH_CONTROLS_INTERCEPT":
                    "{}", "INTEGRITY":
                    "{\"has_more_results\":false,\"processed_unicorn_ids\":[],\"is_end_of_serp\":false}",
                    "SPELLER": "{}", "EVENTS_TAB": "{\"has_more_results\": true,
                    \"browse_cursor_serialized\":
                    \"AbpAmcXQNrmbgdol9PtRSLWeNf-m4VA6TbANr1YufuH-D5Th1CbmddU_S3yuP7YX8k1D62oOop9kWuNArHxHwKeViZ1KPgqXIAA2K1k-AGayFHtcByB2q8YLkF-wsggvKU4hdcxjqXT1ExNHu0iAKzah1rawzrp8nXbB_qEZGKzZ40QT16TlDYIzwSM9_G1D7r1jiHu6EfyENOmuxKySgphyq9auk5iuR2RL6c4XfFrdK9xJRhBOcf6l2KKvM3A2A6GAy8LDbb-4hNSGzg-0P-KX5yE12azb-XiYG1hTmGsInHZQXvFHJsKh3ZOkhgVnXrVKqVKMyIZyE_PYZNY8O4jiRQiWAsbf30-DvgvW2_uzif_zlRHeZVtVy1V5Xy-4iIloZnDs2_hSBJLyFgAtLq_yt6KYagKic1r97ATtvD9oJc_Qvu8flFpQF0m2jjZ7sp0C-ieyXWj_BQrTi4_k-UXSqSYpk0VqQ_C9pXc1J85dy2jA-YNqVlAxm9ccgfNSWfvvgtp1rX37jT2wbUAIC638nQbh4ZDRxcqo-8fBz4wyFPox7NTxVx9n-drqWEnaAKw\",
                    \"processed_unicorn_ids\": [], \"is_end_of_serp\": false}"},
                    "result_ids_shown": [], "unit_id_logging_fields":
                    {"num_total_modules": 1, "num_total_results": 8,
                    "num_total_vertical_results": 8},
                    "entity_ids_shown_by_type": {}, "processed_unicorn_ids": [],
                    "completed_flows": ["INTERNAL_DEBUG_MODULE",
                    "SEARCH_CONTROLS_INTERCEPT", "INTEGRITY", "SPELLER"]}
                requestId: 381414fa-25cc-4882-bef1-7a6cd15a1917
          headers: {}
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '402':
          $ref: '#/components/responses/402'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
      deprecated: false
      security:
        - JWT Bearer: []
components:
  responses:
    '400':
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            example:
              code: 400
              data: null
              message: 'Missing required parameter: handle'
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            example:
              code: 401
              data: null
              message: apiKey is null
    '402':
      description: Payment Required
      content:
        application/json:
          schema:
            type: object
            example:
              code: 402
              data: null
              message: apiKey quota is not enough
    '429':
      description: Too Many Requests
      content:
        application/json:
          schema:
            type: object
            example:
              code: 429
              data: null
              message: qps limit exceeded
    '500':
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            example:
              code: 500
              data: null
              message: Internal server error
  securitySchemes:
    JWT Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |-
        接口鉴权凭证。请在请求 Header 中传入 `Authorization: Bearer <YOUR_API_KEY>`。
        可在 [Dashboard](https://keyapi.ai/app/dashboard) 获取你的 API Key。

````