You can perform Facebook group searches by calling the Meta Content Library API client get()
method with the search/facebook_groups
path. This document describes the parameters, and shows how to perform basic queries by using the method.
All of the examples in this document assume you have already created a Python or R Jupyter notebook and have created a client object. See Getting started to learn more.
See Data dictionary for detailed information about the fields that are available on a Facebook group node.
Parameter | Type | Description |
---|---|---|
| String | Keyword(s) to search for. See Advanced search guidelines for information about how multiple keyword searches with Boolean operators are handled. |
| List | A comma-separated list of group fields you want included in search results. See Data dictionary for descriptions of all available fields. |
| List | A comma-separated list of Meta Content Library group IDs as strings. Limits the query to groups in the list. Maximum of 250 IDs. |
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Facebook groups 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 group.
|
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Facebook groups 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 group.
|
To search for public groups that contain specific keywords, 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_groups",
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
}
You can use the query_next_page()
and has_next_page()
to get the next page of 10 results until all the results have been returned. See Search guide for other display and storage options.
To have the API return only specific fields on any groups in the response, include 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_groups",
params = list("q" = "cybercrime", 'fields' = "id,name")
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
You can search for Facebook groups using specific group IDs obtained from previous group searches.
To get data on specific Facebook groups that contain specific keywords or phrases, create a search object using the get()
method with the q
parameter (specifying the keywords or phrases) and the group_ids
parameter (specifying the list of group IDs you want included). If you omit the q
argument, all groups in the list of IDs are included, not just those with a specific keyword or phrase.
# Search for specific IDs and display specific fields
response <- client$get(
path = "search/facebook_groups",
params = list("group_ids" = list('753110959566351'), 'fields' = "id,name")
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
For using group IDs to search for posts from specific Facebook groups, see Guide to Facebook posts data.