Guide to Facebook Pages data

You can perform Facebook Page searches by calling the Meta Content Library API client get() method with the search/facebook_pages path. This document describes the syntax and parameters and shows how to perform basic queries using the method.

All of the examples in this document assume you have created a Python or R Jupyter notebook and a client object. See Getting started to learn more.

See Data dictionary for detailed information about the fields that are available on a Facebook page node.

Parameters

Parameter Type Description

Q
Optional

String

Keyword(s) to search for. Searches a Page name and description fields. See Advanced search guidelines for information about how multiple keyword searches with Boolean operators are handled.

FIELDS
Optional

List

Comma-separated list of Page fields you want included in search results. See Data dictionary for descriptions of all available fields.

PAGE_IDS
Optional

List

Comma-separated list of Meta Content Library Page IDs as strings. Limits the query to the specified Pages. Maximum of 250 IDs.

CATEGORIES
Optional

List

Comma-separated list of categories to include in the search.

IS_VERIFIED
Optional

Boolean

The verification status of the Facebook Page. A Facebook Page with a verified badge indicates that Facebook has confirmed that it is the authentic presence for that person or brand. Learn more.

WEBSITE
Optional

String

Website to match against the Facebook Page's "About" section.

ADMIN_COUNTRIES
Optional

List

Comma-separated list of countries by which to filter the Facebook Page's admin. Takes ISO Alpha-2 Country Code in 2-letter uppercase format.

SINCE
Optional

String or Integer

Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Facebook Pages created on or after this date or timestamp are returned (used with UNTIL to define a time range). SINCE and UNTIL are based on UTC time zone, regardless of the local time zone of the user who created the Page.

  • If both SINCE and UNTIL are included, the search includes the time range defined by those values.
  • If SINCE is included and UNTIL is omitted, the search includes the SINCE time through the present time.
  • If SINCE is omitted and UNTIL is included, the search goes from the beginning of Facebook time through the UNTIL time.
  • If SINCE and UNTIL are both omitted, the search goes from the beginning of Facebook time to the present time.
  • If SINCE and UNTIL are the same UNIX timestamp, the search includes the SINCE time through the SINCE time plus one hour.
  • If SINCE and UNTIL are the same Date (YYYY-MM-DD), the search includes the SINCE date through the SINCE date plus one day.

UNTIL
Optional

String or Integer

Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Facebook Pages created on or before this date or timestamp are returned (used with SINCE to define a time range). SINCE and UNTIL are based on UTC time zone, regardless of the local time zone of the user who created the Page.

  • If both SINCE and UNTIL are included, the search includes the time range defined by those values.
  • If SINCE is included and UNTIL is omitted, the search includes the SINCE time through the present time.
  • If SINCE is omitted and UNTIL is included, the search goes from the beginning of Facebook time through the UNTIL time.
  • If SINCE and UNTIL are both omitted, the search goes from the beginning of Facebook time to the present time.
  • If SINCE and UNTIL are the same UNIX timestamp, the search includes the SINCE time through the SINCE time plus one hour.
  • If SINCE and UNTIL are the same Date (YYYY-MM-DD), the search includes the SINCE date through the SINCE date plus one day.

Sample queries

Search for Pages by keyword

To search for Pages that contain a specific keyword, use the q parameter. See Advanced search guidelines for information about how multiple keyword searches are handled.

library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient

client$set_default_version(client$LATEST_VERSION)

response <- client$get(
        path = "search/facebook_pages", 
        params = list('q' = "cybercrime")
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page


# Fetch next page
if (client$has_next_page(response)) {
    response <- client$query_next_page(response)
    jsonlite::fromJSON(response$text, flatten=TRUE) # Display second page
}
from metacontentlibraryapi import MetaContentLibraryAPIClient as client

client.set_default_version(client.LATEST_VERSION)

response = client.get(
    path="search/facebook_pages",
    params={"q": "cybercrime"}
)

display(response.json()) # Display first page        
        
# Fetch next page
if client.has_next_page(response):
    response = client.query_next_page(response)
    display(response.json()) # Display second page

This example shows how to iterate through responses by using the query_next_page() method. You can keep calling query_next_page() to get the next page of 10 results, until all the search results have been returned. You can call has_next_page() to check if there is more data. See Search guide for other display and storage options.

Request specific fields

To have the API return only specific fields on any Pages in the response, with the fields parameter and a comma-separated list of fields you want included. If omitted, default fields will be returned.

library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient

client$set_default_version(client$LATEST_VERSION)

response <- client$get(
        path = "search/facebook_pages", 
        params = list("q" = "cybercrime", 'fields' = "id,name")
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
from metacontentlibraryapi import MetaContentLibraryAPIClient as client

client.set_default_version(client.LATEST_VERSION)

response = client.get(
        path="search/facebook_pages", 
        params={q="cybercrime", 'fields':"id,name"}
)
display(response.json()) # Display first page

Search for Pages by Page ID

To search for Pages with specific Page IDs (obtained from the results of previous Page searches), create a search object using the get() method with the page_ids parameter.

response <- client$get(
      path = "search/facebook_pages", 
      params = list("page_ids" = list("282820031228465"), 'fields' = "id,name")
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
response = client.get(
   path="search/facebook_pages", 
   params={"page_ids": ["282820031228465"], 'fields':"id,name"})
display(response.json())

For using Page IDs to search for posts from specific Facebook Pages, see Guide to Facebook posts data.