The actor bundle exposes three focused ways to run the Facebook posts scraper and get results: two synchronous runners that wait for the actor to finish and return results, and one that starts a run and returns run metadata. Each call requires the caller’s Apify token (a top-level argument) and an InputSchema body that controls what the scraper does. Inspect InputSchema before calling to see the fields for target pages/profiles, limits, credentials, and other options.
Core concepts and how resources relate
-
An Actor run produces two common result containers: a dataset (an array of items) and a key-value store (named keys, often
OUTPUT). Which container the scraper writes to depends on the Actor’s implementation and input options. The three operations expose either the dataset items or the key-valueOUTPUT, or return run metadata that references those stores. -
Every operation takes a top-level
tokenand abodymatching theInputSchema. Provide the Apify token with every call; it is not bundled inside thebody. -
The synchronous runners block until the Actor run completes (or the service returns whatever it can). The metadata runner returns a run record immediately with identifiers and status that point to the run, dataset, and key-value store.
Entry points — which operation to call first
Choose an entry point by the result you need:
-
If the user asks for scraped posts as dataset items (an array), call
run-sync-get-dataset-items-apify-facebook-posts-scraper. This is the most direct way to get items in a single call: pass thetokenand theInputSchemathat specifies targets/limits. -
If the user expects the scraper to return a single JSON payload in the key-value store (commonly under the
OUTPUTkey), callrun-sync-apify-facebook-posts-scraper. The response body contains whatever was stored under the key-value store by the Actor. -
If the user only wants to start a run and get run metadata (run id, status, references to dataset or key-value store) — for example to track progress or share the run id — call
runs-sync-apify-facebook-posts-scraper. The response body contains the run record; inspect it forid, timestamps, and references such asdatasetIdorkeyValueStoreId.
Always inspect the returned status field and the body payload: status describes run outcome or state, and body contains the run metadata, dataset items, or key-value output depending on which operation was used.
Common user tasks and the exact pattern to follow
Scrape and return posts immediately as dataset items
- Use
run-sync-get-dataset-items-apify-facebook-posts-scraperwith yourtokenand anInputSchemathat specifies the target page/profile and any limits (date range, max items, filters). - Inspect the response
statusto confirm completion andbodyfor the array of items. Ifbodyis not an array, inspect it for nested fields that hold items (the Actor’s schema can vary).
Scrape and return the key-value OUTPUT JSON
- Use
run-sync-apify-facebook-posts-scraperwithtokenandInputSchema. - Inspect
bodyfor the storedOUTPUTobject (Actor implementations commonly place exported JSON under that key). If the expected object is missing, check the run metadata (see next pattern) to find the key-value store id.
Start a run and get run metadata
- Use
runs-sync-apify-facebook-posts-scraperwithtokenandInputSchema. - Inspect the returned run record in
bodyforid,createdAt,status, and references such asdatasetIdorkeyValueStoreId. Use those identifiers to locate results in subsequent operations or in downstream systems that accept those IDs.
When to prefer metadata over synchronous results
- Start a run (use
runs-sync-...) when the user needs a run id to track, share, or inspect later, or when the run might be long and the caller prefers to poll or query separate systems for results. Use the synchronous runners when the user wants immediate results in a single call.
Practical checks before calling
Before invoking any operation, confirm these three things in the request:
tokenis present at the top level of the arguments.InputSchemaincludes the required targeting/auth fields for the scraper (profile/page identifiers, session/auth fields if the scraper needs authenticated access, and result limits). The exact field names live in the operation’s input schema.- Decide whether you need dataset items, key-value
OUTPUT, or only run metadata — pick the corresponding operation above.
Response handling notes and gotchas
-
bodyis typed asunknownfor the two result-returning operations. Do not assume a single shape. Inspect the top-level structure in the response: it may be an array of items, an object with anitemsordataproperty, or the rawOUTPUTobject. Treat the response as data to be examined rather than relying on fixed keys. -
statusis the canonical quick check for run outcome. Ifstatusshows the run failed or was interrupted, thebodymay be partial or empty. -
The synchronous calls wait for completion. If a scrape takes a long time, the call will block until the Actor finishes or the service decides otherwise. If a user expects a quick reply but the scraping target is large, prefer starting a run and returning metadata.
-
The Actor may require credentials or session information (cookies, tokens) inside
InputSchemato successfully scrape Facebook pages that are not public. CheckInputSchemafor auth-related fields and populate them when the user provides credentials. -
The run metadata returned by
runs-sync-apify-facebook-posts-scraperis the place to find run identifiers (id,datasetId,keyValueStoreId) that persistent systems or follow-up requests might need. If the immediate synchronous result is missing expected data, examine the run record for those identifiers.
Minimal decision checklist
When a user asks to scrape Facebook posts, follow this decision path:
- Do they want the items returned immediately? If yes, call
run-sync-get-dataset-items-apify-facebook-posts-scraper. - Do they want the scraper’s exported JSON (single file/object) from key-value storage? If yes, call
run-sync-apify-facebook-posts-scraper. - Do they only want to start a run and get its id/status? If yes, call
runs-sync-apify-facebook-posts-scraper.
Always pass token and populate InputSchema fields for targets, limits, and any required auth. After the call, inspect status then inspect body to extract items, OUTPUT, or run identifiers as needed.