You can perform WhatsApp channel searches by calling the Meta Content Library API client get() method with the whatsapp/channels/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 WhatsApp channel node.
| Parameter | Type | Description |
|---|---|---|
| String | Keyword(s) to search for. Searches the channel |
| List | Comma-separated list of Meta Content Library WhatsApp channel IDs to include in the search. |
| List | Comma-separated list of category names to include in the search. Keywords can be used to match categories. Categories are visible in the Meta Content Library UI. |
| Enum | Sort mode specifying the order in which channels are returned (only available for synchronous searches). Available options:
Default: |
| Int | Returns channels with the specified minimum number of followers. Can be used with |
| Int | Returns channels with the specified maximum number of followers or fewer. Can be used with |
| Boolean | Whether the channel has a verified badge. |
| Int | Integer from 10 to 50 specifying the page size for search results. |
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. WhatsApp channels created on or after this date or timestamp are returned (used with
|
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. WhatsApp channels created on or before this date or timestamp are returned (used with
|
To search for WhatsApp channels that contain a specific keyword use the get() method with 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="whatsapp/channels/preview", params=list("q"="whatsapp"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first pageYou can 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.
To search for WhatsApp channels that have a follower count within a specific range, use the get() method with the follower_count_min and follower_count_max parameters. You do not have to use both.
The following example returns channels that have 10,000 to 50,000 followers.
response <- client$get(path="whatsapp/channels/preview", params=list("follower_count_min"="10000", "follower_count_max"="50000", "q":"whatsapp"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first pageThe following example shows searching for verified channels with a specified category using the get() method with the is_verified and categories parameters.
response <- client$get(path="whatsapp/channels/preview", params=list("categories"="news", "is_verified"=TRUE, "q"="news"))
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page