# Facebook Hashtag Scraper - Ad Library Search by Hashtag (`khadinakbar/facebook-hashtag-scraper`) Actor

Search Meta Ad Library by hashtag. Returns matching ads, advertisers, creative assets, delivery details, and landing pages. MCP/API-ready.

- **URL**: https://apify.com/khadinakbar/facebook-hashtag-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** MCP servers, Social media
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 ad founds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Facebook Hashtag Scraper — Search the Ad Library by Hashtag

Search the **Facebook (Meta) Ad Library** for every ad creative that uses a given hashtag, and export it as clean, structured JSON. Give it a list of hashtags (`#blackfriday`, `#skincare`, `#realestate`) and get back the advertisers running those tags, their ad copy, call-to-action, creative media, run dates, target platforms, and disclosed impressions — with no Facebook login and no cookies.

### What it does

The Meta Ad Library is the only public, searchable index of Facebook & Instagram advertising. This actor searches it by hashtag and returns one row per matching ad, so you can see exactly who is advertising on a tag and what their creative looks like.

It is **cookieless and login-free**. Requests are routed through resilient data providers (ScrapeCreators primary, SociaVault fallback) and normalized into one stable schema, so a single provider hiccup does not break your run.

> **Note on scope:** Facebook does not expose a public, scrapable feed of *organic* posts by hashtag — `facebook.com/hashtag/<tag>` is login-walled. The Ad Library is the reliable public hashtag surface, so this actor searches **advertising** that uses a hashtag, not organic timeline posts.

### When to use it

- **Competitor ad research** — see every brand bidding on a hashtag and how they position.
- **Creative intelligence** — collect winning ad copy, hooks, CTAs, and image/video creatives for a niche.
- **Campaign monitoring** — track which advertisers are live on a seasonal tag (`#blackfriday`, `#primeday`).
- **Trend & spend signals** — find the highest-impression advertisers on an issue or product hashtag.
- **AI agents (MCP)** — a single hashtag in, structured ad records out — ideal as an agent tool.

Do **not** use it to scrape a specific page's posts (use a Facebook page scraper) or to read organic hashtag timelines (not publicly available).

### Output

One dataset record per ad. Key fields:

| Field | Description |
|---|---|
| `inputHashtag` / `query` | The hashtag you searched. |
| `pageName` / `pageId` / `pageProfileUrl` | The advertiser. |
| `title` / `bodyText` / `caption` | Ad headline and copy. |
| `ctaText` / `ctaType` / `linkUrl` | Call-to-action and destination. |
| `mediaType` / `imageUrls` / `videoUrls` / `cardCount` | Creative format and media. |
| `isActive` / `startDate` / `endDate` / `totalActiveDays` | Run status and timeline (ISO 8601). |
| `publisherPlatforms` | facebook, instagram, messenger, audience\_network. |
| `impressionsText` / `reachEstimate` / `spend` / `currency` | Disclosed reach (mostly for political/issue ads). |
| `categories` / `containsSensitiveContent` / `collationCount` | Ad metadata. |
| `adArchiveId` / `adLibraryUrl` | Open the ad directly in Meta's Ad Library. |
| `provider` / `scrapedAt` | Data source and collection time. |

#### Sample record

```json
{
  "recordType": "ad",
  "inputHashtag": "#blackfriday",
  "pageName": "Acme Store",
  "title": "Black Friday Blowout",
  "bodyText": "Save 50% this weekend only. #blackfriday",
  "ctaText": "Shop Now",
  "linkUrl": "https://acme.example/sale",
  "mediaType": "VIDEO",
  "videoUrls": ["https://video.example/1.mp4"],
  "isActive": true,
  "startDate": "2026-01-01T00:00:00.000Z",
  "publisherPlatforms": ["FACEBOOK", "INSTAGRAM"],
  "impressionsText": "10K-15K",
  "adArchiveId": "123456789",
  "adLibraryUrl": "https://www.facebook.com/ads/library/?id=123456789",
  "provider": "scrapecreators"
}
```

### Pricing

Pay-per-event:

- **Actor start** — $0.00005 per run.
- **Ad found** — **$0.005 per ad** saved to the dataset.

`maxResultsPerHashtag` is your per-hashtag cost cap. 3 hashtags × 50 ads ≈ $0.75. The actor prints the maximum possible cost at the start of every run and the actual billed amount at the end.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `hashtags` | array | — | Required. `#` optional; spaces stripped. |
| `maxResultsPerHashtag` | integer | 50 | 1–1000. Also the cost cap. |
| `country` | string | `ALL` | 2-letter ISO code or `ALL`. |
| `status` | enum | `ACTIVE` | `ACTIVE`, `INACTIVE`, `ALL`. |
| `mediaType` | enum | `ALL` | `IMAGE`, `VIDEO`, `MEME`, … |
| `searchType` | enum | broad | exact-phrase available. |
| `sortBy` | enum | impressions | or relevance. |
| `startDate` / `endDate` | string | — | `YYYY-MM-DD` impressions window. |

#### Example input

```json
{
  "hashtags": ["#blackfriday", "#skincare"],
  "maxResultsPerHashtag": 100,
  "country": "US",
  "status": "ACTIVE",
  "mediaType": "ALL"
}
```

### Using it from the API

```bash
curl -X POST "https://api.apify.com/v2/acts/khadinakbar~facebook-hashtag-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "hashtags": ["#blackfriday"], "maxResultsPerHashtag": 50, "country": "US" }'
```

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_TOKEN")
run = client.actor("khadinakbar/facebook-hashtag-scraper").call(
    run_input={"hashtags": ["#skincare"], "maxResultsPerHashtag": 50}
)
for ad in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(ad["pageName"], ad["title"])
```

### MCP / AI agents

Exposed in the Apify MCP server as `apify--facebook-hashtag-scraper`. A hashtag goes in, structured ad records come out — a clean tool call for competitor and creative research agents.

### Related actors

- **meta-ad-library-scraper** — full Meta Ad Library by advertiser/keyword across Facebook & Instagram.
- **google-ads-transparency-scraper** — Google Ads creatives.
- **tiktok-ads-scraper** — TikTok Creative Center top ads.
- **instagram-hashtag-scraper** — organic Instagram posts by hashtag.

### FAQ

**Does this scrape organic Facebook posts by hashtag?** No. Facebook hashtag timelines are login-walled and not publicly scrapable. This searches the public Ad Library (advertising).

**Do I need cookies or a Facebook login?** No. It is fully cookieless.

**Why are spend and impressions often empty?** Meta only discloses spend/impressions for political and social-issue ads. Commercial ads return creative and timing data but no spend.

**Can I search multiple hashtags?** Yes — pass an array; each is searched and capped independently.

### Legal

This actor collects data from Meta's **public** Ad Library, which Meta publishes for ad transparency. Use it in compliance with Meta's Terms of Service and applicable laws (including data-protection rules such as GDPR/CCPA). You are responsible for how you use the collected data. This tool does not access private, login-gated, or personal content.

# Actor input Schema

## `hashtags` (type: `array`):

List of hashtags to search the Facebook Ad Library for (e.g. \['#blackfriday', 'fitness']). The leading '#' is optional and added automatically; spaces inside a tag are removed ('#summer sale' becomes '#summersale'). Each hashtag is searched independently and matched against ad copy in the Meta Ad Library. This is NOT a Facebook page URL or username - to scrape a page's posts use a Facebook page scraper instead.

## `maxResultsPerHashtag` (type: `integer`):

Maximum number of ads to return for each hashtag (e.g. 50). The actor paginates through the Ad Library until it reaches this cap or runs out of results. Defaults to 50; range 1-1000. You are charged per ad returned, so this is also your per-hashtag cost cap.

## `country` (type: `string`):

Two-letter ISO country code to scope ad delivery (e.g. 'US', 'GB', 'DE'), or 'ALL' for every country. Defaults to 'ALL'. This filters where the ads were shown, not the advertiser's location. Invalid codes fall back to 'ALL'.

## `status` (type: `string`):

Whether to return currently running ads, stopped ads, or both. 'ACTIVE' returns live ads only (default), 'INACTIVE' returns stopped ads, 'ALL' returns both. Active-only is the most useful for competitor monitoring.

## `mediaType` (type: `string`):

Filter ads by creative format. 'ALL' returns every format (default), 'IMAGE' returns image ads, 'VIDEO' returns video ads, 'MEME' returns image-with-text. Use this to study a specific creative style for a hashtag.

## `searchType` (type: `string`):

How the hashtag is matched. 'keyword\_unordered' matches the tag anywhere in the ad (default, broader recall), 'keyword\_exact\_phrase' matches the exact phrase only (higher precision). Use exact phrase when a hashtag is a common substring of other words.

## `sortBy` (type: `string`):

Result ordering. 'total\_impressions' surfaces the highest-reach ads first (default), 'relevancy\_monthly\_grouped' uses Meta's relevance grouping. Impressions-first is best for finding the biggest spenders on a hashtag.

## `startDate` (type: `string`):

Only return ads that were shown on or after this date, in YYYY-MM-DD format (e.g. '2026-01-01'). Leave empty for no lower bound. Use with End date to scope a campaign window.

## `endDate` (type: `string`):

Only return ads that were shown on or before this date, in YYYY-MM-DD format (e.g. '2026-03-31'). Leave empty for no upper bound. Combine with Start date to isolate a specific period.

## `includeRaw` (type: `boolean`):

Set to true to attach the unmodified provider response for each ad under a 'raw' field. Useful for debugging or accessing fields not in the normalized schema. Defaults to false to keep records small and cheap to read.

## `providerOrder` (type: `string`):

Internal data-provider order for testing and fallback control. 'auto' tries ScrapeCreators before SociaVault when both secrets exist (default). 'scrapecreators-first' or 'sociavault-first' force an order. Not relevant to most users.

## Actor input object example

```json
{
  "hashtags": [
    "#blackfriday",
    "#skincare"
  ],
  "maxResultsPerHashtag": 50,
  "country": "US",
  "status": "ACTIVE",
  "mediaType": "ALL",
  "searchType": "keyword_unordered",
  "sortBy": "total_impressions",
  "startDate": "2026-01-01",
  "endDate": "2026-03-31",
  "includeRaw": false,
  "providerOrder": "auto"
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "hashtags": [
        "#blackfriday"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/facebook-hashtag-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "hashtags": ["#blackfriday"] }

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/facebook-hashtag-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "hashtags": [
    "#blackfriday"
  ]
}' |
apify call khadinakbar/facebook-hashtag-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khadinakbar/facebook-hashtag-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/1IZIrFTTM8vXWRSQm/builds/niNlxfQkCwpLcXXVF/openapi.json
