> ## 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.

# Get page ads

<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">per request</span></span>
</div>

## Copy for 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">🤖 Why Code When AI Can Do It For You?</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">Stop writing code like it's 1970! Let AI do the heavy lifting - click the sparkles to copy a perfectly formatted prompt for ChatGPT, Claude, or your favorite AI assistant.</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(`I need to call the following KeyAPI endpoint. Please generate a complete and directly runnable Python example based on the API information provided below.

## API Information

Endpoint: GET https://api.keyapi.ai/v1/facebook/ads_page_search
Summary: Get page ads

Required Headers:
- Authorization: Bearer <YOUR_API_KEY>

Parameters:
- page_id (Required): No description. Example: 118526624562575
- country (Required): No description. Example: US
- active_status (Optional): defualt: ALL. Available values: ALL ACTIVE INACTIVE.
- cursor (Optional): No description.
- sort_by_new (Optional): No description. Example: false

## Code Requirements

- Use the Python \`requests\` library
- Provide a complete and directly runnable example
- Handle HTTP request errors, timeouts, and non-2xx responses
- Handle JSON parsing errors
- Prefer the Example values provided in the API information for sample parameters
- Keep the code simple and avoid unnecessary abstractions or complexity`)}
    >
      <span>✨</span>
      <span>Copy for AI</span>
    </button>
  </div>
</div>


## OpenAPI

````yaml /en/facebook.openapi.json get /v1/facebook/ads_page_search
openapi: 3.0.1
info:
  title: Facebook API English documentation
  description: >-
    The english reference documentation of the Facebook API includes the
    interface's purpose, parameter description, response status, and sample
    structure.
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production-KeyAPI
security:
  - JWT Bearer: []
tags:
  - name: Pages
  - name: Prefiles
  - name: Groups
  - name: Posts and comments
  - name: Evebts
  - name: Ads Library
  - name: Search
  - name: Marketplace
  - name: Games
paths:
  /v1/facebook/ads_page_search:
    get:
      tags:
        - Ads Library
      summary: Get page ads
      parameters:
        - name: page_id
          in: query
          description: ''
          required: true
          example: '118526624562575'
          schema:
            type: string
            example: '118526624562575'
        - name: country
          in: query
          description: ''
          required: true
          example: US
          schema:
            type: string
            example: US
        - name: active_status
          in: query
          description: |-
            defualt: ALL. Available values:
            ALL
            ACTIVE
            INACTIVE
          required: false
          schema:
            type: string
        - name: cursor
          in: query
          description: ''
          required: false
          schema:
            type: string
        - name: sort_by_new
          in: query
          description: ''
          required: false
          example: 'false'
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 0
                message: success
                data:
                  ads:
                    - ad_archive_id: '1623486605837756'
                      collation_count: 1
                      collation_id: '1087189690507310'
                      is_active: true
                      page_id: '118526624562575'
                      page_is_deleted: false
                      snapshot:
                        branded_content: null
                        page_id: '118526624562575'
                        page_is_deleted: false
                        page_profile_uri: https://facebook.com/TemuPoland
                        root_reshared_post: null
                        byline: null
                        disclaimer_label: null
                        page_name: Temu Poland
                        page_profile_picture_url: >-
                          https://scontent-bos5-1.xx.fbcdn.net/v/t39.35426-6/818262696_1657415535952157_8268807946708984970_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=107&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=6sx_0jO9R0EQ7kNvwEIVCMJ&_nc_oc=AdqwwSslkJ-nixawy6-2JXVsU0Vpenlm3rrQIWSnZpUmcMX8AfVDndvzIm_vkOZy1xI&_nc_zt=14&_nc_ht=scontent-bos5-1.xx&_nc_gid=bzQYJkvu0-edIYA8UpXzAQ&_nc_ss=7d289&oh=00_AQLLbDMHgM_5f3v8-7Ct4_vwrIZmw8cHo75Gk55iT-YVFg&oe=6AB80F7B
                        event: null
                        caption: www.temu.com
                        cta_text: Shop now
                        cards: []
                        body:
                          text: >-
                            Duża deska do krojenia idealna na blat kuchenny.
                            Wystarczająca na warzywa, mięso i pieczywo
                            jednocześnie. 🔪🥦🍞 Znajdziesz ją pod
                            https://temu.to/m/e3hlkcza7gt lub z kodem fdb7936.
                            #Temu #OdkryciaTemu #Kuchnia
                        cta_type: SHOP_NOW
                        display_format: VIDEO
                        link_description: null
                        link_url: >-
                          https://www.temu.com/ul/kuiper/un1.html?subj=feed-un&_bg_fs=1&_p_mat1_type=1&_p_jump_id=725&_x_vst_scene=adg&locale_override=211~~USD&adg_ctx=a-627f0c24&goods_id=601099944287601&_p_rfs=1&_x_ads_channel=kol_metabca&_x_ads_sub_channel=official&_x_cid=Bm5PXBEs_43400672_kol_official_instagram_official&_x_bg_adid=udp2013414079&_x_ads_set={{campaign.id}}&_x_ads_id={{adset.id}}&_x_ads_creative_id={{ad.id}}&_x_ns_source={{site_source_name}}&_x_ns_placement={{placement}}
                        images: []
                        page_categories:
                          - Shopping
                        page_like_count: 441894
                        title: null
                        videos:
                          - video_hd_url: >-
                              https://video-bos5-1.xx.fbcdn.net/o1/v/t2/f2/m367/AQP_s7lt1h9Tfv5mU0UVIbxElHpiZSoRmp1KqdXs_VXmxSA9y1rlcyJgsfMcsYm67mgG9FaOgEQS6j2hReUjmE-97ZQTmBNJut37AQ_Ckg.mp4?_nc_cat=101&_nc_sid=ef5aa3&_nc_ht=video-bos5-1.xx.fbcdn.net&_nc_ohc=MgArh--b8ysQ7kNvwHe07cc&efg=eyJ2ZW5jb2RlX3RhZyI6Inhwdl9wcm9ncmVzc2l2ZS5WSV9VU0VDQVNFX1BST0RVQ1RfVFlQRS4uQzMuNzIwLnByb2dyZXNzaXZlX2gyNjQtYmFzaWMtZ2VuMl83MjBwIiwieHB2X2Fzc2V0X2lkIjoxODAwMzEzNzE2ODk5NTg4MCwiYXNzZXRfYWdlX2RheXMiOjE3LCJ2aV91c2VjYXNlX2lkIjoxMjM3NCwiZHVyYXRpb25fcyI6MTcsInVybGdlbl9zb3VyY2UiOiJ3d3cifQ%3D%3D&ccb=17-1&_nc_gid=bzQYJkvu0-edIYA8UpXzAQ&_nc_ss=7d289&_nc_zt=28&oh=00_AQKhmEhcDRcw_QNlvRtEUhamU6nnx8Ob1dvUD3dNiFeCZg&oe=6AB7F695
                            video_preview_image_url: >-
                              https://scontent-bos5-1.xx.fbcdn.net/v/t39.35426-6/815922050_1410508084542466_8132844064606268888_n.jpg?_nc_cat=104&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=LWbA8FF07-oQ7kNvwGQn3Vz&_nc_oc=AdpAvYmfzcDKNfarsjlBckmo6FxA1pWjUUYYdQY6S45QkeLgcEn1rlIXaGqKdlyLi0g&_nc_zt=14&_nc_ht=scontent-bos5-1.xx&_nc_gid=bzQYJkvu0-edIYA8UpXzAQ&_nc_ss=7d289&oh=00_AQJKx0NCocPKxYN4WcIAbcBXdilArEUmXcaKSiNmpqKifw&oe=6AB7FA77
                            video_sd_url: >-
                              https://video-bos5-1.xx.fbcdn.net/o1/v/t2/f2/m367/AQPvPhxcaoy9vo1P0QpMqDePIXmqFt8pxpKWj_y24sVzAMg3uchFfy_ryElArsfbKnco9bKSq-hNUIvavIcYep-Dm1qi04R4PPUg7dldWg.mp4?_nc_cat=110&_nc_sid=ef5aa3&_nc_ht=video-bos5-1.xx.fbcdn.net&_nc_ohc=QErz4ECnZHQQ7kNvwH3q5NC&efg=eyJ2ZW5jb2RlX3RhZyI6Inhwdl9wcm9ncmVzc2l2ZS5WSV9VU0VDQVNFX1BST0RVQ1RfVFlQRS4uQzMuMzYwLnByb2dyZXNzaXZlX2gyNjQtYmFzaWMtZ2VuMl8zNjBwIiwieHB2X2Fzc2V0X2lkIjoxODAwMzEzNzE2ODk5NTg4MCwiYXNzZXRfYWdlX2RheXMiOjE3LCJ2aV91c2VjYXNlX2lkIjoxMjM3NCwiZHVyYXRpb25fcyI6MTcsInVybGdlbl9zb3VyY2UiOiJ3d3cifQ%3D%3D&ccb=17-1&_nc_gid=bzQYJkvu0-edIYA8UpXzAQ&_nc_ss=7d289&_nc_zt=28&oh=00_AQI8HGV4Z2wVZPhIfLpt8KyI8YuspgK4rmAk-IOlAJSQ3A&oe=6AB81E84
                            watermarked_video_hd_url: null
                            watermarked_video_sd_url: null
                        is_reshared: false
                        extra_links: []
                        extra_texts: []
                        extra_images: []
                        extra_videos: []
                        country_iso_code: null
                        brazil_tax_id: null
                        additional_info: null
                        ec_certificates: []
                      has_user_reported: false
                      report_count: null
                      menu_items: []
                      state_media_run_label: null
                      page_name: Temu Poland
                      impressions_with_index:
                        impressions_text: <100
                        impressions_index: 0
                      gated_type: ELIGIBLE
                      categories:
                        - UNKNOWN
                      is_aaa_eligible: false
                      contains_digital_created_media: false
                      reach_estimate: null
                      currency: ''
                      spend: null
                      end_date: 1790060400
                      publisher_platform:
                        - FACEBOOK
                        - INSTAGRAM
                        - AUDIENCE_NETWORK
                        - THREADS
                      start_date: 1789887600
                      contains_sensitive_content: false
                      total_active_time: null
                      regional_regulation_data:
                        finserv:
                          is_deemed_finserv: false
                          is_limited_delivery: false
                        tw_anti_scam:
                          is_limited_delivery: false
                      hide_data_status: NONE
                      fev_info: null
                      ad_id: null
                      targeted_or_reached_countries: []
                  cursor: null
                requestId: abbe2c45-1205-4541-9008-42444edf2d9a
          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: |-
        API key for authentication. Format: `sk_live_xxxxxxxxxxxxx`
        Get your API key from the [Dashboard](http://keyapi.ai/app/dashboard).

````