You can work with Meta Content Library API within Meta Researcher Platform or within an approved third-party cleanroom environment. The getting started procedure documented here is specific to Researcher Platform which runs a modified version of Jupyter and provides you with a virtual data cleanroom where you can securely search for and analyze data. If you are accessing the Content Library API through a third-party cleanroom environment, you will be provided with getting started instructions from the cleanroom's system administrator.
If you are accessing the Content Library API through a third-party cleanroom environment such as the one provided by ICPSR, you will be provided with getting started instructions from the cleanroom's system administrator. Please be sure to follow their instructions as this page only provides information relevant to the Meta Researcher Platform cleanroom.
To get up and running with Content Library API in Researcher Platform:
OpenVPN access to Researcher Platform extended
Based on your feedback on our release of the Amazon WorkSpaces Secure Browser, we are making improvements to ensure a smoother transition. You will continue to have access to the Researcher Platform through OpenVPN. As we make these updates, please note that your current environments and data remain unaffected. We will communicate a revised timeline soon.
The Log in to the Researcher Platform URL section on this page provides the URL for accessing Meta Content Library API through WorkSpaces Secure Browser so you can try it.
This remainder of this section shows you how to install and configure the OpenVPN client and connect to our VPN server. Once connected, you will be able to access Researcher Platform and use Content Library API.
When the setup wizard completes, OpenVPN Connect launches and you will be required to accept the OpenVPN Inc. Data Collection, Use and Retention policy to continue.
In the Import Profile window, select the UPLOAD FILE tab.
Clicking this link downloads the OpenVPN configuration file (fortVpnCredentials.ovpn) to your computer (check your downloads folder). Once downloaded, drag and drop the file into the Import Profile window.
In the Imported Profile window, click CONNECT.
Once successfully connected, you will see this window:
While you are connected to our VPN server, all of your internet traffic is routed through it, so be sure to disconnect when you are finished.
While connected to the VPN, go to the Researcher Platform URL.
Alternatively, you can use the Amazon WorkSpaces Secure Browser version of Researcher Platform without being connected to the VPN. See WorkSpaces Secure Browser in the Researcher Platform user documentation for information.
With either option, log into the site using your Facebook credentials. This will spin up an instance of JupyterHub server for your use in Researcher Platform.
You will be offered the choice of CPU or GPU server. See GPU server to learn more about the difference between the two. See Researcher Platform for complete Researcher Platform documentation.
In the Launcher window, click the icon for Python3 or R. This will create a new Jupyter Notebook in a new browser tab. To rename the notebook, right-click the notebook in the left navigation bar and select Rename.
You enter queries in the blank cells of the notebook. To run a query, click the run icon in the top toolbar.
All calls are made using the Content Library API Client. You only need to import the Content Library API client once per Jupyter notebook server session.
In code block examples in this documentation, select the R or Python tab to see the corresponding code. You can copy the code and paste it into your notebook.
library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient
# Set specific MCL_API_VERSION, or use client$LATEST_VERSION to get the latest
client$set_default_version(client$LATEST_VERSION)
Test your setup by running a basic search query. Here is an example to try for Facebook Pages:
library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient
client$set_default_version(client$LATEST_VERSION)
# Search for Facebook Pages
pages_response <- client$get(
path="search/facebook_pages",
params = list("q"="mountains")
)
jsonlite::fromJSON(pages_response$text, flatten=TRUE) # Display first page
Test fetching an entity by its ID (obtained from the results of a previous search) such as one of the Pages from the previous query:
pages_data <- jsonlite::fromJSON(pages_response$text, flatten=TRUE)$data
page_mcl_id <- pages_data[c('id')][1,]
# Fetch by Meta Content Library ID
response <- client$get(path=page_mcl_id)
jsonlite::fromJSON(response$text, flatten=TRUE)