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

# Search Ad Library

> Retrieve a list of LinkedIn Ads matching the specified search criteria.

Scrape [LinkedIn Ad Library Search](https://www.linkedin.com/ad-library/search) to find ads based on various criteria such as keywords, account owners, countries, and date ranges.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const params = new URLSearchParams({
    keyword: 'sales',
    accountOwner: 'ai',
    countries: 'US,CA,FR',
    dateOption: 'custom-date-range',
    startdate: '2025-01-01',
    enddate: '2025-12-31',
  });

  fetch(`https://api.harvestapi.io/linkedin/ad-library?${params.toString()}`, {
    headers: { 'X-API-Key': '<api-key>' },
  })
    .then((response) => response.json())
    .then((data) => console.log(data));
  ```

  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.harvestapi.io/linkedin/ad-library?keyword=sales&accountOwner=ai&countries=US,CA,FR&dateOption=custom-date-range&startdate=2025-01-01&enddate=2025-12-31 \
    --header 'X-API-Key: <api-key>'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.harvestapi.io/linkedin/ad-library?keyword=sales&accountOwner=ai&countries=US,CA,FR&dateOption=custom-date-range&startdate=2025-01-01&enddate=2025-12-31"

  headers = {"X-API-Key": "<api-key>"}

  response = requests.request("GET", url, headers=headers)

  print(response.text)
  ```
</CodeGroup>


## OpenAPI

````yaml GET /linkedin/ad-search
openapi: 3.0.1
info:
  title: HarvestAPI LinkedIn API reference
  description: HarvestAPI LinkedIn API reference
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.harvestapi.io
security:
  - ApiKeyAuthHeader: []
paths:
  /linkedin/ad-search:
    get:
      summary: Search LinkedIn Ad Library
      description: Retrieve a list of LinkedIn Ads matching the specified search criteria.
      parameters:
        - name: searchUrl
          in: query
          description: >-
            Scrape Ad Library search URL, for example:
            https://www.linkedin.com/ad-library/search?accountOwner=test&keyword=test&dateOption=custom-date-range&startdate=2025-07-07&enddate=2025-08-21
          schema:
            type: string
        - name: keyword
          in: query
          description: Search by keyword
          schema:
            type: string
        - name: accountOwner
          in: query
          description: Search by company or advertiser name
          schema:
            type: string
        - name: countries
          in: query
          description: >-
            One or comma separated list of country codes to filter ads by
            country. Eg. 'US,GB,FR'. Supports "ALL" value to search in all
            countries.
          schema:
            type: string
        - name: dateOption
          in: query
          description: >-
            One of the following options to filter ads by date: 'last-30-days',
            'current-month', 'current-year', 'last-year', 'custom-date-range'
          schema:
            type: string
        - name: startdate
          in: query
          description: Start date for 'custom-date-range' filter in 'YYYY-MM-DD' format
          schema:
            type: string
        - name: enddate
          in: query
          description: End date for 'custom-date-range' filter in 'YYYY-MM-DD' format
          schema:
            type: string
        - name: paginationToken
          in: query
          description: >-
            Pagination token from the previous response for fetching the next
            page
          schema:
            type: string
            format: nullable
      responses:
        '200':
          description: A list of ads matching the search criteria.
          content:
            application/json:
              schema:
                type: object
                properties:
                  elements:
                    type: array
                    items: 05eeb4b1-9492-41ec-bbb9-2aeeedb7a08a
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                    type: object
                  status:
                    type: string
                    description: Status of the response.
                  error:
                    type: string
                    description: Error message, if any.
                  query:
                    type: object
                    properties:
                      search:
                        type: string
        '400':
          description: Invalid request parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Pagination:
      type: object
      properties:
        totalPages:
          type: integer
          format: int32
        totalElements:
          type: integer
          format: int32
        pageNumber:
          type: integer
          format: int32
        previousElements:
          type: integer
          format: int32
        pageSize:
          type: integer
          format: int32
        paginationToken:
          type: string
          format: nullable
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    ApiKeyAuthHeader:
      type: apiKey
      in: header
      name: X-API-Key

````