You can perform Facebook fundraiser searches by calling the Meta Content Library API client get() method with the facebook/fundraisers/preview path. This document describes the parameters, and shows how to perform basic queries using the method.
All of the examples in this document are taken from a Secure Research Environment use case and assume you have created a 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 fundraisers node.
| Parameter | Type | Description |
|---|---|---|
| String | Keyword(s) to search for. Searches fundraiser |
| Enum | Sort mode specifying the order in which fundraisers are returned (only available for synchronous searches). Available options:
Default: |
| List | Comma-separated list of fundraiser category names to include in the search (only available for fundraisers where the beneficiary is a nonprofit). Keywords can be used to match categories. Categories are visible in the Meta Content Library UI. |
| List | Comma-separated list of countries to include. This refers to countries of the nonprofit associated with the fundraiser. Only available for fundraisers where the beneficiary is a nonprofit. Takes ISO Alpha-2 Country Code in 2-letter uppercase format. |
| List | Comma-separated list of nonprofit IDs to include (only available for fundraisers where the beneficiary is a nonprofit). |
| List | Comma-separated list of Meta Content Library Owner IDs as strings. Limits the query to fundraisers organized by owners 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. Fundraisers created on or after this date or timestamp are returned (used with UNTIL to define a time range).
|
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Fundraisers created on or before this date or timestamp are returned (used with
|
To search for fundraisers whose title or description contain specific keywords, use the q parameter. See Advanced search guidelines for information about how multiple keyword searches are handled.
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.
library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient
client$set_default_version(client$LATEST_VERSION)
response <- client$get(path="facebook/fundraisers/preview", params=list("q"="animals"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
# Fetch next page
if (client$has_next_page(response)) {
response <- client$query_next_page(response)In addition to searching for fundraisers based on a keyword, this example limits the results to fundraisers in a specified country.
response <- client$get(path="facebook/fundraisers/preview", params=list("nonprofit_countries"="US", "q"="children"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first pageThis example retrieves fundraisers in the specified categories whose title or description match the specified keyword. You can consult the Meta Content Library UI for the current list of available categories.
response <- client$get(path="facebook/fundraisers/preview", params=list("nonprofit_categories"="education, health", "q"="children"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first pageTo search for fundraisers benefitting specific nonprofits, use the NONPROFIT_IDS parameter, providing IDs you obtained from the results of previous queries. This type of search is only available for fundraisers where the beneficiary is a nonprofit.
response <- client$get(path="facebook/fundraisers/preview", params=list("nonprofit_ids"= list("1687800528495896","2258893424505921"), "q"="children"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first pageSimilar to searching based on specific nonprofit IDs, you can also search based on specific owner IDs, as shown in the following example. Again, you would have obtained the IDs from the results of a previous search.
response <- client$get(path="facebook/fundraisers/preview", params=list("owner_ids"="1278397396204099", "q"="animals"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page