# Facebook User Search Scraper: Related Profiles & Pages (`simpleapi/facebook-user-search-scraper`) Actor

🔍 Facebook User Search Scraper pulls public Facebook user search results—names, profile URLs, locations, and work/education snippets—for precise targeting. ⚡ Ideal for lead gen, recruiting, and market research. 📦 Fast, accurate, and export-ready (CSV/JSON).

- **URL**: https://apify.com/simpleapi/facebook-user-search-scraper.md
- **Developed by:** [SimpleAPI](https://apify.com/simpleapi) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 14 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

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/actors/running/actors-in-store.md#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 People Search Scraper — Profiles, Family and Employer Pages

Find Facebook profiles by name or keyword and pull structured data for each match: **name**, **userId**, **profileUrl**, **profileImage**, work/education history (**userData**), and two network-adjacent fields most profile scrapers skip — **relatedProfiles** (spouse/partner and named family members) and **affiliatedPages** (employer, school, hometown and current-city Facebook Pages). Investigators, recruiters, and lead-research teams use it to turn a bare name into a public profile plus its disclosed real-world connections. No Facebook login is required to run it.

### What is Facebook User Search Scraper: Related Profiles & Pages?

Facebook User Search Scraper: Related Profiles & Pages searches Facebook for profiles matching a name or keyword (via Google's `site:facebook.com` index), fetches each matching profile's public page, and returns one structured JSON record per profile — including the relationship/family links and employer/school/city Facebook Pages that profile has made public on its own Intro card. No Facebook account, login, or cookies are used at any point; every page is fetched logged-out.

- **Discovery by name/keyword or direct URL** — `searchNames` runs a Google dork search per query; `directProfileUrls` scrapes specific profile URLs directly, in addition to or instead of search
- **Core identifying fields** — name, numeric `userId`, canonical `profileUrl`, profile photo, cover photo, and up to 20 additional public photos
- **Network-adjacent data** — `relatedProfiles` (spouse/partner + named family members, each with a real Facebook profile link) and `affiliatedPages` (employer/school/hometown/current-city Pages), both pulled from the profile's own page, not an algorithmic recommendation feed
- **Work/education history** — `userData` entries pulled from Facebook's About section
- **Real filters** — toggle each network-adjacent feature independently, cap related-profile entries per row, or drop rows with no network data at all
- **Auto proxy escalation** — Facebook requests start with no proxy and step up to datacenter, then residential, only when a request looks blocked

### What data can I extract with Facebook User Search Scraper: Related Profiles & Pages?

Every scraped profile is normalized into one dataset row covering identity, network, work history and media fields:

| Field | Example Value | Use Case |
| --- | --- | --- |
| `name` | `"Mark Zuckerberg"` | Identify the profile owner |
| `accountType` | `"person"` | Separate personal profiles from Page-type accounts |
| `profileUrl` | `"https://www.facebook.com/zuck"` | Canonical link back to the live profile |
| `userId` | `"4"` | Stable numeric Facebook ID for de-duplication and joins |
| `relatedProfiles` | `[{"name":"Priscilla Chan","profileUrl":"https://www.facebook.com/priscilla","relationshipType":"Married to Priscilla Chan since May 19, 2012","isVerified":true}]` | Map disclosed spouse/family connections |
| `relatedProfileCount` | `1` | Quick filter/sort on how many related profiles were found |
| `affiliatedPages` | `[{"name":"Meta","pageUrl":"https://www.facebook.com/Meta","affiliationType":"employer","isVerified":true}]` | Turn a personal profile into a company or school Page lookup |
| `affiliatedPageCount` | `2` | Quick filter/sort on affiliation richness |
| `userData` | `[{"type":"work","text":"Founder and CEO at Meta","icon":"https://static.xx.fbcdn.net/rsrc.php/ye/r/Wc6P-qNdeGZ.webp"}]` | Work/education background for research |
| `profileImage` | `"https://scontent.xx.fbcdn.net/.../p480x480_....jpg"` | Visual identity confirmation |
| `coverImage` | `"https://scontent.xx.fbcdn.net/.../s960x960_....jpg"` | Additional visual context |
| `images` | `["https://scontent.xx.fbcdn.net/.../....jpg"]` | Extra public profile photos (up to 20) |
| `sourceQuery` | `"Mark Zuckerberg"` | Trace which input query or URL produced the row |
| `scrapedAt` | `"2026-07-16T12:00:00Z"` | Freshness timestamp for the record |

#### Related profiles and Page affiliations

`relatedProfiles` and `affiliatedPages` are the fields that separate this Actor from a plain name/photo profile scraper. `relatedProfiles` comes from the profile's own Intro card relationship entry plus its `/about_family_and_relationships` page — each entry carries `name`, `profileUrl`, `relationshipType` (e.g. "Married to Priscilla Chan since May 19, 2012") and `isVerified`. `affiliatedPages` comes from the same Intro card's work/education/city cards — each entry has `name`, `pageUrl`, `affiliationType` (`employer`, `school`, `hometown` or `currentCity`) and `isVerified`. In practice, this means one search on a name returns not just the profile but its disclosed spouse, family members, and the company/school Pages it is linked to — useful for building a first-pass relationship map without ever touching a followers or friends list.

#### Targeting data

`sourceQuery` ties every row back to the input query or direct URL that produced it, so results from a batch of names stay attributable. `accountType` (`"person"` vs `"page"`) lets you filter out business/public-figure Pages, which rarely carry relationship or family data. `relatedProfileCount` and `affiliatedPageCount` let you sort or filter for the richest records first, and `affiliationType` values (`employer`, `school`, `hometown`, `currentCity`) let you segment affiliated Pages by connection type rather than reading the whole array.

### Why not build this yourself?

Facebook has no public API for arbitrary user or profile search, so reaching a profile from just a name means dorking Google's index first — this Actor runs `site:facebook.com` searches plus three follow-up dork variants (`inurl:profile`, `profile.php`, generic `profile`) per query just to assemble a usable set of candidate URLs. Fetching work/education history requires calling Facebook's internal GraphQL endpoint, which means extracting a `doc_id` from obfuscated JS bundles and reconstructing session variables (`rawSectionToken`, `sectionToken`, `pageID`, `userID`, `collectionToken`) by regex-matching Facebook's minified Relay payloads — logic that breaks the moment Facebook reshuffles its bundle format. The `relatedProfiles` and `affiliatedPages` extraction works the same way: it scans raw HTML for `timeline_context_list_item_type` markers (`INTRO_CARD_WORK`, `INTRO_CARD_RELATIONSHIP`, etc.) inside fixed-size text windows, because Facebook doesn't expose this data as a clean API response. On top of the parsing, every request has to detect soft blocks (HTTP 400/401/403/429/5xx, or a 200 response with a "Sorry, something went wrong" body and no `og:title` tag) and escalate through a no-proxy → datacenter-proxy → residential-proxy ladder to keep working.

Building this in-house makes sense only if you need a narrower, custom extraction and have engineering time to track Facebook's markup changes indefinitely. For a maintained pipeline that already handles SERP discovery, GraphQL token reconstruction, and proxy escalation, running the Actor directly is the faster path.

### How to use data extracted from Facebook?

#### People search and investigation research

Investigators, journalists, and due-diligence teams enter one or more names in `searchNames`, leave `includeRelatedProfiles` and `includePageAffiliations` on, and get back each matching profile with its disclosed spouse/family (`relatedProfiles`) and employer/school Pages (`affiliatedPages`) in the same row. Because every field comes from the profile's own public page, the output can be used as a starting point for verifying a subject's public connections — for example, confirming a family relationship or an employer before a background check — without scraping a followers or friends list, which Facebook keeps behind login for nearly every profile.

#### Recruiting and prospecting agencies

Agencies sourcing candidates or sales prospects run a batch of names through `searchNames` with `onlyProfilesWithAffiliations` enabled, so only profiles carrying real work-history or Page-affiliation data are kept. The `affiliatedPages` entry with `affiliationType: "employer"` turns each candidate's personal profile straight into a link for the hiring company's own Facebook Page, saving a separate company lookup per candidate in a recurring sourcing run.

#### Market research and intelligence

Researchers scraping a batch of profiles in one niche (an industry, a school alumni network, a region) can aggregate the `affiliatedPages` array across rows to see which employer and school Pages recur most often, using `affiliationType` to separate employer density from school density. Combined with `accountType`, this gives a lightweight view of which organizations a searched population is publicly connected to, without needing access to any Page's own follower list.

#### AI agents and automated pipelines

An agent given a name can call this Actor as a tool, receive `name`, `relatedProfiles`, and `affiliatedPages` for the best-matching profile, and use that structured context to enrich a CRM record or answer a research question — all through the same JSON the Actor already returns, with no separate parsing step required.

### 🔼 Input sample

None of the 9 input parameters are required — the Actor runs with any combination of `searchNames` and/or `directProfileUrls`.

| Parameter | Required | Type | Description | Example Value |
| --- | --- | --- | --- | --- |
| `searchNames` | No | array | One or more names/keywords; each is searched on Google (`site:facebook.com` dork) to discover matching Facebook profile URLs. | `["Mark Zuckerberg"]` |
| `maxProfilesToScrape` | No | integer (min 1, max 50000) | Maximum number of Facebook profiles to scrape in this run. Defaults to 10 if omitted. | `10` |
| `directProfileUrls` | No | array | Facebook profile URLs to scrape directly, in addition to search results. | `["https://www.facebook.com/zuck"]` |
| `includeRelatedProfiles` | No | boolean (default `true`) | Extract relationship/family related profiles from the profile's own page. | `true` |
| `includePageAffiliations` | No | boolean (default `true`) | Extract employer/school/hometown/current-city Page affiliations from the profile's Intro card. | `true` |
| `maxRelatedProfilesPerItem` | No | integer (default 0, min 0, max 100) | Cap how many `relatedProfiles` entries are kept per row. `0` = unlimited. | `10` |
| `onlyProfilesWithAffiliations` | No | boolean (default `false`) | Drop a row if it has both an empty `relatedProfiles` list and an empty `affiliatedPages` list. | `false` |
| `requestDelaySeconds` | No | integer (min 0, max 10) | Delay in seconds before each Facebook profile fetch. Defaults to 1 if omitted. | `1` |
| `proxyConfiguration` | No | object (proxy editor) | Proxy for Facebook requests. Google search always uses a dedicated SERP proxy regardless of this setting. | `{"useApifyProxy": true}` |

```json
{
  "searchNames": ["Mark Zuckerberg"],
  "maxProfilesToScrape": 10,
  "includeRelatedProfiles": true,
  "includePageAffiliations": true,
  "onlyProfilesWithAffiliations": false,
  "requestDelaySeconds": 1
}
```

**Common pitfall:** `searchNames` and `directProfileUrls` are both optional, but at least one must contain something — if both are left empty, the run finds zero URLs to scrape and produces no dataset rows.

### 🔽 Output sample

Every result is pushed to the dataset in real time as a typed, normalized JSON record — one object per scraped profile, exportable as JSON, CSV, Excel, or the other standard Apify dataset formats.

```json
{
  "name": "Mark Zuckerberg",
  "accountType": "person",
  "profileUrl": "https://www.facebook.com/zuck",
  "userId": "4",
  "relatedProfiles": [
    {
      "name": "Priscilla Chan",
      "profileUrl": "https://www.facebook.com/priscilla",
      "relationshipType": "Married to Priscilla Chan since May 19, 2012",
      "isVerified": true
    }
  ],
  "relatedProfileCount": 1,
  "affiliatedPages": [
    {
      "name": "Meta",
      "pageUrl": "https://www.facebook.com/Meta",
      "affiliationType": "employer",
      "isVerified": true
    },
    {
      "name": "Harvard University",
      "pageUrl": "https://www.facebook.com/Harvard",
      "affiliationType": "school",
      "isVerified": true
    }
  ],
  "affiliatedPageCount": 2,
  "userData": [
    {
      "type": "work",
      "text": "Founder and CEO at Meta",
      "icon": "https://static.xx.fbcdn.net/rsrc.php/ye/r/Wc6P-qNdeGZ.webp"
    },
    {
      "type": "education",
      "text": "Studied Computer Science at Harvard University",
      "icon": "https://static.xx.fbcdn.net/rsrc.php/v3/y5/r/TJztmYBP2MH.png"
    }
  ],
  "profileImage": "https://scontent.xx.fbcdn.net/v/t39.30808-1/priscilla_p480x480.jpg",
  "coverImage": "https://scontent.xx.fbcdn.net/v/t39.30808-6/cover_s960x960.jpg",
  "images": [
    "https://scontent.xx.fbcdn.net/v/t39.30808-6/photo1.jpg",
    "https://scontent.xx.fbcdn.net/v/t39.30808-6/photo2.jpg"
  ],
  "sourceQuery": "Mark Zuckerberg",
  "scrapedAt": "2026-07-16T12:00:00Z"
}
```

### How do you filter and target specific profiles?

Two inputs control search scope: `searchNames` runs a free-text/name query through Google's Facebook index — the right choice for discovery when you only have a name — while `directProfileUrls` skips discovery entirely and scrapes exact profiles, which is more accurate whenever you already have the profile link and don't want SERP noise. The two can be combined in a single run; direct URLs are always processed alongside whatever the name search finds.

Volume is controlled at two levels. `maxProfilesToScrape` (1–50,000) caps the total number of profiles scraped in the run, while `maxRelatedProfilesPerItem` (0–100, default unlimited) separately caps how many `relatedProfiles` entries are kept *inside* each row — useful when a profile links a long family list and you only need the top few. `requestDelaySeconds` (0–10) paces the requests sent to Facebook per profile.

For quality, `onlyProfilesWithAffiliations` drops any row where both `relatedProfiles` and `affiliatedPages` came back empty — mostly Page-type/business profiles that don't carry Intro-card relationship or work data — so the output only contains profiles with real network signal. `includeRelatedProfiles` and `includePageAffiliations` can each be turned off independently to skip the corresponding extraction entirely and finish the run faster when you only need one of the two.

```json
{ "searchNames": ["Jane Smith", "Jane Smith Chicago"], "maxProfilesToScrape": 25 }
```

```json
{ "directProfileUrls": ["https://www.facebook.com/zuck"], "onlyProfilesWithAffiliations": true, "maxRelatedProfilesPerItem": 10 }
```

```json
{ "searchNames": ["John Carter"], "maxProfilesToScrape": 500, "includeRelatedProfiles": false, "includePageAffiliations": false, "requestDelaySeconds": 0 }
```

### ▶️ Want to try other Facebook scrapers?

| Scraper Name | What it extracts |
| --- | --- |
| Facebook Page Posts & Comments Scraper | Posts and comments from a Facebook Page |
| 🔍 Facebook Posts Search Scraper | Posts matching a keyword search across Facebook |
| Facebook Groups Search Scraper With Group Profile Details | Facebook Groups matching a search, with group profile details |
| Facebook Comments Scraper: Sentiment & Toxicity Analysis | Comments on posts, scored for sentiment and toxicity |
| LinkedIn Profile Scraper | Professional profile data from LinkedIn |
| Instagram Followers Count Scraper | Follower counts for Instagram accounts |

### How to extract Facebook data programmatically

The Actor runs as a standard Apify Actor: one API call starts the run, and results land in a dataset you can read back as structured JSON over REST.

#### Python example

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("SimpleAPI/facebook-user-search-scraper-related-profiles-pages").call(
    run_input={
        "searchNames": ["Mark Zuckerberg"],
        "maxProfilesToScrape": 10,
        "includePageAffiliations": True,
    }
)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["name"], item["profileUrl"], item["affiliatedPages"])
```

#### MCP for AI agents

The Actor is reachable through Apify's Actors MCP Server by listing it in the `--tools` flag:

```bash
npx @apify/actors-mcp-server --tools SimpleAPI/facebook-user-search-scraper-related-profiles-pages
```

An agent connected this way can look up a name and pull back the matching profile's `relatedProfiles` and `affiliatedPages` as a tool call, useful for enrichment steps in a research or CRM agent. Compatible with any MCP-aware client, including Claude Desktop and Claude Code.

#### Export to spreadsheets or CRM

Dataset results export directly to CSV or Excel from the Apify Console, or via the API. Map `name`, `profileUrl`, `userId` and `affiliatedPages` (filtered to `affiliationType: "employer"`) onto CRM contact/company columns to enrich lead records without manual copy-paste.

### Is it legal to scrape Facebook user profiles?

Scraping public Facebook profile pages is generally lawful in most jurisdictions, since this Actor only reads pages Facebook serves without login — the same pages any logged-out visitor or search engine can see. That said, the records returned (names, family relationships, work history, photos) are personal data under regimes like the GDPR and CCPA, so storing, matching, or reusing them at scale carries a lawful-basis and retention obligation on you, not on the Actor. Facebook's own Terms of Service also restrict automated data collection, independent of privacy law. Consult legal counsel for commercial applications involving bulk storage of personal data.

### ❓ FAQ

#### What happens if a profile has been deleted, deactivated, or made fully private?

The Actor detects blocked or empty responses (missing `og:title`, an error body, or an HTTP 400/401/403/429/5xx status) and skips that profile entirely rather than saving a fabricated or empty row — it will not appear in the output.

#### Can I get the related-profile and Page-affiliation data along with the main profile record?

Yes, both are included by default. `includeRelatedProfiles` and `includePageAffiliations` are both `true` unless you turn them off, and each populated row carries them alongside the base name/photo/work-history fields in the same object.

#### How accurate is the family and employer data?

The Actor returns exactly what each profile's own Intro card and About page show at request time — it never infers or guesses a relationship or employer. Accuracy depends entirely on whether the profile owner has filled in and kept that section current; treat it as a public self-declaration, not a verified record.

#### How many profiles can I get per run?

Up to 50,000, set via `maxProfilesToScrape` (minimum 1). If the parameter is omitted, the run defaults to 10 profiles.

#### How does `onlyProfilesWithAffiliations` change the output?

It drops any row where both `relatedProfiles` and `affiliatedPages` came back empty — mostly business/Page-type profiles — so every remaining row has at least one real network-adjacent data point, useful when you want a shorter, higher-signal list instead of every match.

#### Does Facebook User Search Scraper: Related Profiles & Pages work with Claude, ChatGPT, and AI agent frameworks?

Yes. It is registered as a tool through Apify's Actors MCP Server (`npx @apify/actors-mcp-server --tools SimpleAPI/facebook-user-search-scraper-related-profiles-pages`) for MCP-aware clients, and it is callable as a standard HTTP API endpoint by any agent framework that can make a REST call.

#### How does this compare to other Facebook profile scrapers?

Most Facebook profile scrapers return name, photo, and work/education history only. This Actor adds two fields most tools don't attempt: `relatedProfiles` (disclosed spouse/family links) and `affiliatedPages` (employer/school/hometown/city Pages), both pulled from data the profile itself makes public — not an algorithmic recommendation feed, which Facebook does not expose to logged-out requests at all.

#### Can I use this without a Facebook API key or developer account?

Yes. No Facebook login, cookie, API key, or developer account is needed — only an Apify account to run the Actor. Facebook itself has no public API that supports arbitrary user/profile search, which is why this Actor works through Google's index and public profile pages instead.

#### Will this scraper find someone's "People You May Know" suggestions or their liked Pages/joined Groups?

No — and it's honest about this rather than faking it. Live testing across multiple profile types found no "People You May Know" carousel and no "Pages Liked"/"Groups Joined" tabs anywhere in the logged-out profile payload; that content is only ever rendered to a logged-in viewer. `relatedProfiles` and `affiliatedPages` are the real, on-page substitutes this Actor extracts instead.

### Conclusion

Facebook User Search Scraper: Related Profiles & Pages turns a name or keyword into a structured Facebook profile record — plus the family relationships and employer/school Pages that profile has already made public. It's built for people-search and investigation research, recruiting and prospecting teams, and market researchers who need more than a name and a photo, with the filtering controls to keep only the rows with real network signal. Open the Actor in Apify Console, add a name under `searchNames`, and start a run to see it on your own data.

# Actor input Schema

## `searchNames` (type: `array`):

One or more names/keywords. Each is searched on Google (site:facebook.com dork) to discover matching Facebook profile URLs. Same field as the base actor's 'queries' (that key still works if you send it directly).

## `maxProfilesToScrape` (type: `integer`):

Maximum number of Facebook profiles to scrape in this run (1-50000). Same as the base actor's 'maxItems'.

## `directProfileUrls` (type: `array`):

Paste Facebook profile URLs here to scrape directly, in addition to search results. Same as the base actor's 'startUrls'.

## `includeRelatedProfiles` (type: `boolean`):

Extract related/linked profiles surfaced on the searched profile's own page: relationship status (spouse/partner) and named family members from the public About > Family and relationships section — each with a real Facebook profile link. This is Facebook's own on-page relationship data, not an algorithmic 'People You May Know' feed (confirmed absent from every logged-out profile payload tested).

## `includePageAffiliations` (type: `boolean`):

Extract Facebook Pages the profile is publicly linked to via its Intro card: employer Page, school Page, hometown Page, current-city Page. Facebook's native 'Pages Liked' and 'Groups Joined' profile tabs are not present on any logged-out profile (confirmed on 5 test profiles of different types) — see README for the honest coverage breakdown.

## `maxRelatedProfilesPerItem` (type: `integer`):

Cap how many relatedProfiles entries are kept per scraped profile. 0 = unlimited.

## `onlyProfilesWithAffiliations` (type: `boolean`):

When enabled, a profile row is dropped from the output if it has BOTH an empty relatedProfiles list AND an empty affiliatedPages list (e.g. most Page-type/business profiles).

## `requestDelaySeconds` (type: `integer`):

Delay in seconds before each Facebook profile fetch (0-10). Same as the base actor's 'requestDelay'.

## `proxyConfiguration` (type: `object`):

Google search uses a dedicated SERP proxy. For Facebook requests: no proxy by default; auto-escalates to datacenter then residential if a request looks blocked.

## Actor input object example

```json
{
  "searchNames": [
    "mark"
  ],
  "maxProfilesToScrape": 10,
  "directProfileUrls": [
    "https://www.facebook.com/markzuckerberg"
  ],
  "includeRelatedProfiles": true,
  "includePageAffiliations": true,
  "maxRelatedProfilesPerItem": 0,
  "onlyProfilesWithAffiliations": false,
  "requestDelaySeconds": 1
}
```

# Actor output Schema

## `results` (type: `string`):

All scraped items in the Actor's default dataset.

# 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 = {
    "searchNames": [
        "mark"
    ],
    "maxProfilesToScrape": 10,
    "directProfileUrls": [
        "https://www.facebook.com/markzuckerberg"
    ],
    "requestDelaySeconds": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("simpleapi/facebook-user-search-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 = {
    "searchNames": ["mark"],
    "maxProfilesToScrape": 10,
    "directProfileUrls": ["https://www.facebook.com/markzuckerberg"],
    "requestDelaySeconds": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("simpleapi/facebook-user-search-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 '{
  "searchNames": [
    "mark"
  ],
  "maxProfilesToScrape": 10,
  "directProfileUrls": [
    "https://www.facebook.com/markzuckerberg"
  ],
  "requestDelaySeconds": 1
}' |
apify call simpleapi/facebook-user-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,simpleapi/facebook-user-search-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/7QGAJStALcY2uJMVv/builds/Ymq07ZdMPoiTMrzHT/openapi.json
