facebook
facebook-ads

Search Facebook Ad Library

Searches the Facebook Ad Library for ads matching a keyword. Returns matching ads with creative text, images, sponsor info, and status.

get/facebook/adlibrary/search/ads

Request

  • Base URL: https://www.socialcrawl.dev/v1
  • URL: https://www.socialcrawl.dev/v1/facebook/adlibrary/search/ads
  • Auth: API key in header x-api-key

Query parameters

querystring required

Search keyword or phrase to find ads in the Facebook Ad Library

sort_by'total_impressions' | 'relevancy_monthly_grouped'

Sort by impressions (high to low), or Most Recent (relevancy_monthly_grouped). Defaults to impressions.

search_type'keyword_unordered' | 'keyword_exact_phrase'

If you want to search by exact phrase or not

ad_type'all' | 'political_and_issue_ads'

Search for all ads or only political and issue ads

countrystring

This can only be one country. It has to be the 2 letter code for the country. It defaults to ALL.

status'ALL' | 'ACTIVE' | 'INACTIVE'

Status of the ad. Defaults to ACTIVE.

media_type'ALL' | 'IMAGE' | 'VIDEO' | 'MEME' | 'IMAGE_AND_MEME' | 'NONE'

Media type of the ad. Defaults to ALL. Meme just means the ad has text and an image. No clue why they call it meme.

start_datestring

Impressions start date. Needs to be in YYYY-MM-DD format.

end_datestring

Impressions end date. Needs to be in YYYY-MM-DD format.

cursorstring

Cursor to paginate through results

trimboolean

Set to true for a trimmed down version of the response

Headers

Cache-Controlstring

Send no-cache to bypass the response cache and force a live fetch. Billed at the normal endpoint cost; the fresh result is written back to cache for the next caller. Only the no-cache directive triggers this. See the Response Schema guide for details.

Idempotency-Keystring

Optional UUID that makes the request safely retriable. The key is reserved atomically per account before billing. A concurrent retry receives 409 IDEMPOTENCY_IN_PROGRESS with a Retry-After of 1 second while the original is young, growing to a quarter of the time it has been running (at most 30); a crashed reservation expires after 5 minutes. A replay keeps the cached payload immutable except for billing metadata: credits_used becomes 0, idempotent_replay becomes true, and credits_remaining is refreshed to the current balance. A known current balance appears in both the body and X-Credits-Remaining header; no balance row resolves to 0. On a transient lookup failure, body credits_remaining is null and X-Credits-Remaining is omitted. Completed outcomes expire after 24 hours. If the claim store is unavailable, the request fails closed before billing. GET endpoints do not combine idempotent replay with Server-Sent Events: use Accept: application/json when sending this header. The unsupported key-plus-SSE combination is rejected before billing.

Response

Successful response

successboolean required

Whether the request succeeded

platformstring required

Platform name

endpointstring required

API endpoint path

credits_usedinteger required

Number of credits consumed

credits_remaininginteger nullable required

Current account balance, or null when this response could not establish one. Free cache hits always return null because they do not establish an authoritative post-request balance. An idempotency replay also returns null when its current-balance lookup fails. It is never a fabricated zero, so a zero here means the account really is empty. The authoritative reading is the one on a billed response, which comes straight from the deduction.

request_idstring required

Unique request identifier for support

cachedboolean required

Whether the response was served from cache

idempotent_replayboolean

True only when this response is an idempotency replay

Example response

{
  "success": true,
  "platform": "facebook",
  "endpoint": "/v1/facebook/adlibrary/search/ads",
  "credits_used": 1,
  "credits_remaining": 4999,
  "request_id": "req-abc123",
  "idempotent_replay": true,
  "meta": {
    "hint": {
      "code": "search_multi",
      "message": "You searched \"matcha\" on 3 platforms one call at a time; /v1/search/multi returns each platform's own search rows in one call at the same price per platform, and a platform with no rows is not charged.",
      "method": "GET",
      "path": "/v1/search/multi?query=matcha&platforms=instagram,tiktok,youtube"
    }
  },
  "pagination": {
    "next_cursor": "sc.eyJ2IjoyLCJjIjoiMiIsInAiOiJwYWdlIn0",
    "has_more": true,
    "page_size": 30,
    "stopped_at": "known_id"
  }
}

Changes