# Facebook URL to ID (`bornoo/facebook-url-to-id`) Actor

Extract numeric Facebook IDs from any profile, page, or post URL. Simply input a Facebook link and the actor parses the URL structure or page source to find the underlying ID. Fast, reliable, and works with profile.php links, vanity usernames, and page URLs alike.

- **URL**: https://apify.com/bornoo/facebook-url-to-id.md
- **Developed by:** [Biddut Hossain](https://apify.com/bornoo) (community)
- **Categories:** AI, Agents, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 URL to ID

Extract numeric Facebook IDs from any profile, page, or post URL. Simply input a Facebook link and the actor parses the URL structure or page source to find the underlying ID. Fast, reliable, and works with profile.php links, vanity usernames, and page URLs alike.

### What does this Actor do?

Facebook profiles, pages, and posts can be linked to using a "vanity" username (e.g. `facebook.com/zuck`) or a numeric ID (e.g. `facebook.com/profile.php?id=4`). Many tools and integrations — ad platforms, CRMs, data pipelines — require the underlying numeric ID rather than the username.

This Actor takes a Facebook URL as input and returns the corresponding numeric Facebook ID by:

1. Checking if the ID is already present in the URL structure (e.g. `profile.php?id=...`)
2. If not, fetching the page and scanning the HTML/meta tags for the embedded ID

### Input

The Actor accepts a single JSON input:

| Field         | Type   | Required | Description                                  |
|---------------|--------|----------|-----------------------------------------------|
| `facebookUrl` | string | Yes      | The Facebook profile, page, or post URL to resolve |

**Example input:**

```json
{
  "facebookUrl": "https://www.facebook.com/zuck"
}
```

### Output

The Actor pushes one result item to the dataset per run:

```json
{
  "inputUrl": "https://www.facebook.com/zuck",
  "facebookId": "4",
  "success": true
}
```

| Field        | Description                                      |
|--------------|---------------------------------------------------|
| `inputUrl`   | The original URL provided as input                |
| `facebookId` | The extracted numeric Facebook ID, or `null` if not found |
| `success`    | Boolean indicating whether an ID was successfully extracted |

### How to use

1. Open the Actor in Apify Console.
2. Paste a Facebook profile, page, or post URL into the **Facebook URL** input field.
3. Click **Start**.
4. View the extracted ID in the **Output** / **Dataset** tab.

### Supported URL formats

- `https://www.facebook.com/profile.php?id=XXXXXXXXX`
- `https://www.facebook.com/username`
- `https://www.facebook.com/pages/Page-Name/XXXXXXXXX`
- Post and page URLs containing an embedded numeric ID

### Limitations

- Facebook may show a login wall or heavily obfuscate page source for some public pages when accessed anonymously, which can occasionally prevent ID extraction from page content.
- This Actor does not log in to Facebook and only accesses publicly available page data.
- Extremely JavaScript-heavy pages may require a headless browser (e.g. Playwright) for full reliability — the current version uses lightweight HTTP requests for speed.

### Support

If you run into an issue or a URL format that doesn't resolve correctly, please open an issue or reach out via Apify Console support.

## Actor input object example

```json
{}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("bornoo/facebook-url-to-id").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("bornoo/facebook-url-to-id").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call bornoo/facebook-url-to-id --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=bornoo/facebook-url-to-id",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/d4KWa39L21KeOREB3/builds/CxygwVshM6kW300cK/openapi.json
