You can perform searches for Instagram creator, business, and certain personal accounts by calling the Meta Content Library API client get()
method method, with the search/instagram_accounts
path.
For personal accounts, only those that have account privacy set to public, and have either a verified badge or 25,000* or more followers are included. This document describes the parameters and shows how to perform basic queries by using this method.
*v2.0 will continue to only fetch personal accounts that have account privacy set to public with either a verified badge or 50,000 or more followers.
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 an Instagram account node.
Parameter | Type | Description |
---|---|---|
| String | Keyword(s) to search Instagram accounts for. See Advanced search guidelines for information about how multiple keyword searches with Boolean operators are handled. |
| List | A comma-separated list of Instagram account fields you want included in search results. See Data dictionary for descriptions of all available fields. |
| List | Comma-separated list of Meta Content Library Instagram account IDs to include in the search results. Maximum of 250 IDs. |
| List | Comma-separated list of account types of the Instagram accounts to be included in the search results. Possible values are Public Instagram accounts include professional accounts for businesses and creators. They also include a subset of personal accounts that have privacy set to public and have either a verified badge or 25,000* or more followers. A verified badge in this context refers to accounts confirmed as authentic and not those with a paid Meta Verified subscription. *v2.0 will continue to include a subset of personal accounts that have privacy set to public with either a verified badge or 50,000 or more followers. |
| Boolean | Whether the Instagram account is verified. An Instagram account with a legacy blue verified badge means that Instagram has confirmed that it is the authentic presence for that person or brand. Learn more. |
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Instagram accounts 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 account.
|
| String or Integer | Date in YYYY-MM-DD (date only) or UNIX timestamp (translates to a date and time to the second) format. Instagram accounts 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 account.
|
To search for Instagram accounts 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 = "search/instagram_accounts",
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
}
This example would return only 10 results per 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 Instagram accounts in the response, use the get()
method with the fields
parameter and a comma-separated list of fields you want included. If omitted, default fields will be returned. To more easily see columns of data, this example specifies a DataFrame response format (the default response format is JSON).
library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient
client$set_default_version(client$LATEST_VERSION)
response <- client$get(
path = "search/instagram_accounts",
params = list('q'="cybercrime", 'fields'='id,name,biography')
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
You can search for Instagram accounts using specific account IDs obtained from previous account searches.
To get data on specific Instagram accounts that contain specific keywords or phrases, use get()
the account_ids
parameter (specifying the list of account IDs you want included). If you omit the q
argument, all accounts in the list of IDs are included, not just those with a specific keyword or phrase.
library(reticulate)
client <- import("metacontentlibraryapi")$MetaContentLibraryAPIClient
client$set_default_version(client$LATEST_VERSION)
response <- client$get(
path = "search/instagram_accounts",
params = list("account_ids"=list("315242517956050"))
)
jsonlite::fromJSON(response$text, flatten=TRUE) # Display first page
For using Instagram account IDs to search for posts from specific Instagram accounts, see Guide to Instagram posts data.