{
  "openapi": "3.0.1",
  "info": {
    "title": "LinkedIn Ad Library API",
    "description": "FastAPI-based scraper for the public LinkedIn Ad Library. Search ads by advertiser, keyword or payer, filter by country, date range, impressions and targeting facets, and pull per-ad detail including creatives, impressions and targeting parameters.",
    "version": "1.9",
    "x-build-id": "LpHxC8JzuD0DpLZGF"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/experthasan~linkedin-ad-library-api/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-experthasan-linkedin-ad-library-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/experthasan~linkedin-ad-library-api/runs": {
      "post": {
        "operationId": "runs-sync-experthasan-linkedin-ad-library-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/experthasan~linkedin-ad-library-api/run-sync": {
      "post": {
        "operationId": "run-sync-experthasan-linkedin-ad-library-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "searchType"
        ],
        "properties": {
          "searchType": {
            "title": "Search Type",
            "enum": [
              "advertiser",
              "keyword",
              "payer",
              "ad_details"
            ],
            "type": "string",
            "description": "What to search the Ad Library by",
            "default": "advertiser"
          },
          "accountOwner": {
            "title": "Advertiser Name",
            "type": "string",
            "description": "Company or advertiser name, e.g. 'Microsoft'. Required when searchType is 'advertiser'.",
            "default": "Microsoft"
          },
          "companyIds": {
            "title": "Company IDs",
            "type": "array",
            "description": "LinkedIn numeric company IDs to restrict the search to. Optional; more precise than a name.",
            "items": {
              "type": "string"
            }
          },
          "keyword": {
            "title": "Keyword",
            "type": "string",
            "description": "Free-text term to match in ad copy. Required when searchType is 'keyword'."
          },
          "payer": {
            "title": "Payer",
            "type": "string",
            "description": "The entity that paid for the ads. Required when searchType is 'payer'."
          },
          "adId": {
            "title": "Ad ID",
            "type": "string",
            "description": "Numeric ad ID from a linkedin.com/ad-library/detail/<id> URL. Required when searchType is 'ad_details'."
          },
          "countries": {
            "title": "Countries",
            "type": "array",
            "description": "Two-letter country codes to filter by, e.g. US, GB, DE. Leave empty for all countries.",
            "items": {
              "type": "string"
            }
          },
          "dateOption": {
            "title": "Date Range",
            "enum": [
              "last-30-days",
              "current-month",
              "current-year",
              "last-year",
              "custom-date-range"
            ],
            "type": "string",
            "description": "Preset date range. Ignored if Start Date or End Date is set.",
            "default": "last-30-days"
          },
          "startDate": {
            "title": "Start Date",
            "type": "string",
            "description": "Custom range start (YYYY-MM-DD). Setting this switches Date Range to custom."
          },
          "endDate": {
            "title": "End Date",
            "type": "string",
            "description": "Custom range end (YYYY-MM-DD). Setting this switches Date Range to custom."
          },
          "impressionsMinValue": {
            "title": "Minimum Impressions",
            "minimum": 0,
            "type": "integer",
            "description": "Only return ads with at least this many impressions, in the unit below (e.g. 10 + thousands = 10,000)."
          },
          "impressionsMaxValue": {
            "title": "Maximum Impressions",
            "minimum": 0,
            "type": "integer",
            "description": "Only return ads with at most this many impressions, in the unit below."
          },
          "impressionsUnit": {
            "title": "Impressions Unit",
            "enum": [
              "none",
              "thousand",
              "million"
            ],
            "type": "string",
            "description": "Unit applied to the impression bounds. LinkedIn's own filter defaults to thousands.",
            "default": "thousand"
          },
          "includedTargetingFacetCategories": {
            "title": "Included Targeting Categories",
            "type": "array",
            "description": "Only return ads that used these targeting categories",
            "items": {
              "type": "string",
              "enum": [
                "LANGUAGE",
                "LOCATION",
                "AUDIENCE",
                "DEMOGRAPHIC",
                "COMPANY",
                "EDUCATION",
                "JOB",
                "INTERESTS_AND_TRAITS"
              ]
            }
          },
          "excludedTargetingFacetCategories": {
            "title": "Excluded Targeting Categories",
            "type": "array",
            "description": "Exclude ads that used these targeting categories",
            "items": {
              "type": "string",
              "enum": [
                "LANGUAGE",
                "LOCATION",
                "AUDIENCE",
                "DEMOGRAPHIC",
                "COMPANY",
                "EDUCATION",
                "JOB",
                "INTERESTS_AND_TRAITS"
              ]
            }
          },
          "fetchAdDetail": {
            "title": "Fetch Ad Details (required for video files)",
            "type": "boolean",
            "description": "Open each ad's detail page. Required to get video files (the search page has none), untruncated ad copy, CTA, landing page and payer. One extra request per ad.",
            "default": false
          },
          "maxResults": {
            "title": "Maximum Results",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Stop after this many ads",
            "default": 100
          },
          "pageSize": {
            "title": "Page Size",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Ads requested per page (the Ad Library serves 25)",
            "default": 25
          },
          "maxPages": {
            "title": "Maximum Pages",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Hard cap on pages walked. Leave empty to derive it from Maximum Results."
          },
          "proxyConfiguration": {
            "title": "Proxy Configuration",
            "type": "object",
            "description": "Route requests through Apify Proxy. Recommended for larger runs.",
            "default": {
              "useApifyProxy": true
            }
          },
          "paginationToken": {
            "title": "Pagination Token",
            "type": "string",
            "description": "Continue a previous run. Copy next_pagination_token from that run's PAGINATION record in the key-value store. Pair it with Skip."
          },
          "skip": {
            "title": "Skip",
            "minimum": 0,
            "type": "integer",
            "description": "Ads to skip on the first page when continuing. Copy next_skip from the previous run's PAGINATION record.",
            "default": 0
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}