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

Facebook URL to ID: paste Facebook Page, group, event or post links, handles or mobile links and get the numeric Facebook ID, object type, name and canonical URL. Free. Batch input with dedupe and a status per line. Personal profiles are skipped. No login.

- **URL**: https://apify.com/datahamster/facebook-url-to-id.md
- **Developed by:** [Viktor Dubnytskiy](https://apify.com/datahamster) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Facebook URL to ID

Free. Paste Facebook Page, group, event or post links in any form and get back the numeric Facebook ID, the object type, the name and Facebook's canonical URL, one row per line you pasted. No login, no cookies.

**Try it:** the prefilled example returns 6 rows in about 10 seconds. The actor is free; you pay only Apify platform usage (about $0.002 for the example).

Coverage: public Pages, public groups, events and posts. Personal profiles are recognised and skipped on purpose (no ID, no name, no URL). Objects that Facebook says do not exist come back as `not_found`; private groups and anything Facebook only shows behind its login page come back as `unavailable`.

### Why this one

- **Paste anything, not only desktop links.** Bare handles (`nasa`, `@nasa`), numeric IDs, `m.facebook.com`, `web.facebook.com`, `fb.com`, `/pg/` and `/pages/<name>/<id>` links, tracking parameters: all are normalized to one www.facebook.com URL before the lookup. In the example, `https://m.facebook.com/Microsoft/?ref=bookmarks` resolves to `100064903443387`.
- **Duplicates are resolved once.** The example lists NASA twice (`nasa` and `profile.php?id=100044561550831`); the second row is marked `duplicateOf: "nasa"` and is not fetched again. An exact repeat of a line gets its own row too, so the output always has one row per input line (`line` = position in your list).
- **Every line gets an answer with a status.** `ok`, `ok_unverified`, `not_found`, `unavailable`, `blocked`, `invalid` or `skipped`, so a 500-line list can be joined back on `line` without guessing which lines failed.
- **IDs that the URL already carries cost no request.** Group post permalinks, reels, `watch?v=` and `story_fbid` links are answered instantly as `ok_unverified` (read from the link, not checked against Facebook).
- **Same input format as other Facebook ID tools.** A saved `fbUrls: [{"url": ...}]` input can be pasted as-is.

### What you get

Real rows from the example dataset:

| input | type | id | name | status |
|---|---|---|---|---|
| `nasa` | page | 100044561550831 | NASA - National Aeronautics and Space Administration | ok |
| `https://m.facebook.com/Microsoft/?ref=bookmarks` | page | 100064903443387 | Microsoft | ok |
| `https://www.facebook.com/groups/pythonprogramminglanguage/` | group | 692268140863644 | Python | ok |
| `https://www.facebook.com/events/1343159087434618/` | event | 1343159087434618 | New York Rangers vs. Philadelphia Flyers | ok |
| `https://www.facebook.com/NASA/posts/pfbid02hwYX8...` | post | 1671214107707292 | | ok |
| `https://www.facebook.com/profile.php?id=100044561550831` | page | 100044561550831 | NASA - National Aeronautics and Space Administration | ok, duplicateOf `nasa` |

Full row: `line`, `input`, `url` (normalized; `/<post id>` for posts, empty for profiles), `type`, `id`, `name`, `status`, `canonicalUrl`, `category` (Pages, e.g. "Government organization"), `legacyPageId` (the classic Page ID when Facebook still shows it, e.g. NASA `54971236771`), `duplicateOf`, `duplicateOfLine`, `skipped`, `tier`, `scrapedAt`.

If you are moving from a tool that returns the classic Page ID, that number is in `legacyPageId`; `id` is the current Page profile ID.

For posts `canonicalUrl` is the neutral `https://www.facebook.com/<post id>` permalink.

### Next step: our Facebook scrapers

You have the ID; these actors (paid per result, no login) take the same Pages, groups and events further:

- [Facebook Events Scraper](https://apify.com/datahamster/facebook-events-scraper): events of a Page or a city search, with dates, place and counts.
- [Facebook Comments Scraper](https://apify.com/datahamster/facebook-comments-scraper): comments of public posts, text and counts.
- [Facebook Pages Search Scraper](https://apify.com/datahamster/facebook-pages-search): find Pages by keyword and city, with business contacts.
- [Facebook Groups Search Scraper](https://apify.com/datahamster/facebook-groups-search): find public groups by keyword, with member counts.
- [Facebook Reels Scraper](https://apify.com/datahamster/facebook-reels-videos): reels and view counts of a Page.

### Input

| Field | Meaning | Default |
|---|---|---|
| `urls` | URLs, handles or numeric IDs, one per line | 6 example lines |
| `fbUrls` | Optional `[{"url": ...}]` list, the format other Facebook ID tools use; merged with `urls` | empty |
| `maxItems` | Rows to return, one per input line; lines past it are not processed | `1000` |

For lists longer than 1,000 lines raise `maxItems`. When it cuts a list, the run log and the `RUN_SUMMARY` record (`unprocessedLines`) say how many lines were left out.

### Cost

The actor itself is free. Apify bills platform usage (compute and proxy traffic) to your account: Pages, events and posts are read without a proxy where Facebook allows it, public groups need a residential IP (about 0.2 MB of residential traffic per group in the example).

**Found it useful?** A short review on the Store page helps other people find this actor. If something is wrong, open an issue on the actor page.

### How it works

1. Each line is normalized: host, path form and tracking parameters are cleaned, the object type is read from the path.
2. IDs already in the URL (group posts, reels, watch links) are returned directly.
3. Everything else is read from the page Facebook serves to logged-out visitors (`fb://profile/<id>`, `fb://group/<id>`, `eventID`, the canonical post URL). Four lookups run in parallel with short pauses. When Facebook answers with its login page, the lookup is retried on a datacenter and then a residential IP; public groups go straight to residential and get a second try on a fresh residential session.
4. A line is `not_found` only when Facebook says "This content isn't available right now". A line that gets the login page on every IP is `unavailable` (missing, private or walled: Facebook does not say which). A line refused outright on every IP is `blocked`.
5. A run in which nothing resolved, nothing was proven missing and at least one line hit a wall ends as blocked, so a walled run is never mistaken for an empty answer.

### Limits

- Personal profiles are never resolved: the row says `type: "profile"`, `status: "skipped"` and carries no ID or name. A Page is resolved only when Facebook marks it as a Page.
- Private and secret groups and objects visible only to logged-in users come back as `unavailable`.
- Post names are not returned (post text can name people); use the ID.
- Share links (`/share/...`) and `fb.me` links are followed, but Facebook does not always redirect logged-out visitors.

### FAQ

**Which ID do I get for a Page?** The current Page profile ID that Facebook uses in its apps (`fb://profile/<id>`). When Facebook still exposes the classic Page ID, it is in `legacyPageId`.

**Does it need a Facebook account?** No. There is no login or cookie field.

**Why was a line skipped?** It points to a personal profile. Resolving people is out of scope.

### Changelog

- 0.1: initial release: Pages, groups, events and posts; handle and mobile-link normalization; per-line status; duplicates resolved once; free; profiles and posts never carry a URL that names a person.

# Actor input Schema

## `urls` (type: `array`):

One per line. Any form works: https://www.facebook.com/nasa, m.facebook.com/nasa, fb.com/nasa, @nasa, nasa, profile.php?id=..., /groups/<name>, /events/<id>, post, reel and watch links. Duplicates are resolved and charged once.

## `fbUrls` (type: `array`):

Optional. The \[{"url": ...}] list format other Facebook ID tools use, so a saved input can be pasted as-is. Merged with the list above.

## `maxItems` (type: `integer`):

Rows to return, one per input line; lines past it are not processed.

## Actor input object example

```json
{
  "urls": [
    "nasa",
    "https://m.facebook.com/Microsoft/?ref=bookmarks",
    "https://www.facebook.com/groups/pythonprogramminglanguage/",
    "https://www.facebook.com/events/1343159087434618/",
    "https://www.facebook.com/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
    "https://www.facebook.com/profile.php?id=100044561550831"
  ],
  "maxItems": 20
}
```

# Actor output Schema

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

All pushed rows (dataset, JSON)

## `resultsTable` (type: `string`):

Dataset in the Console viewer

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

RUN_SUMMARY record

# 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 = {
    "urls": [
        "nasa",
        "https://m.facebook.com/Microsoft/?ref=bookmarks",
        "https://www.facebook.com/groups/pythonprogramminglanguage/",
        "https://www.facebook.com/events/1343159087434618/",
        "https://www.facebook.com/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
        "https://www.facebook.com/profile.php?id=100044561550831"
    ],
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahamster/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 = {
    "urls": [
        "nasa",
        "https://m.facebook.com/Microsoft/?ref=bookmarks",
        "https://www.facebook.com/groups/pythonprogramminglanguage/",
        "https://www.facebook.com/events/1343159087434618/",
        "https://www.facebook.com/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
        "https://www.facebook.com/profile.php?id=100044561550831",
    ],
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("datahamster/facebook-url-to-id").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 '{
  "urls": [
    "nasa",
    "https://m.facebook.com/Microsoft/?ref=bookmarks",
    "https://www.facebook.com/groups/pythonprogramminglanguage/",
    "https://www.facebook.com/events/1343159087434618/",
    "https://www.facebook.com/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
    "https://www.facebook.com/profile.php?id=100044561550831"
  ],
  "maxItems": 20
}' |
apify call datahamster/facebook-url-to-id --silent --output-dataset

```

## MCP server setup

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

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/1Qpe8Mj4nFbHwJcNF/builds/AL3hfGugCGDBN2N9H/openapi.json
