Ratings and Insights
Learn how to get a page's ratings and insights.
We'll cover the following
View ratings
Facebook users use the rating feature on a page to share their opinions and experiences about a product, business, or service. Users can give a rating on a scale of one to five stars. They can also write a review and share a comment about their experience. All users' ratings are combined to make an overall page rating, which is displayed on the page and in the search results. Higher ratings can help a page stand out and gain more followers. They also help new users to trust the product/service, which drives sales. Editors and admins manage page ratings and respond to reviews and comments. The base URL for the endpoint above is:
https://graph.facebook.com/v16.0/{page_id}/ratings
Request parameters
The following are the request parameters of the above endpoint.
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received in response after making the call to the |
| Boolean | Optional | This tells whether to include a summary of the page's ratings or not. The summary contains the number of ratings and the overall rating of the page. |
| String | Optional | This specifies the maximum number of results we want in the response. |
To view ratings on the page using the Facebook Graph API, we can make a GET
request to the ratings
edge of the page
object using the page's ID and a page access token that has the pages_read_user_content
permission. Click the “Run” button to see the response.
// Importing libraries hereimport fetch from "node-fetch"// Define endpoint URL hereconst endpointUrl = new URL("https://graph.facebook.com/v16.0/{{PAGE_ID}}/ratings");const headerParameters = {contentType: "application/json",};// Setting API call optionsconst options = {method: "GET",headers: headerParameters,};// Define Query Parameters hereconst queryParameters = new URLSearchParams({access_token: '{{PAGE_ACCESS_TOKEN}}',limit: '10'});// Function to make API callasync function fetchPageRatings() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(error);}}// Calling function to make API callfetchPageRatings();
In the code widget above:
Line 5: We define the endpoint URL in the
endpointUrl
variable.Lines 18–21: We add the
access_token
and set thelimit
to10
to specify the maximum number of results to return in response in thequeryParameters
variable.Line 27: We use the
fetch
function to make the API call.
Response fields
The response fields for the above endpoints are given in the table below.
Name | Type | Description |
| String | This is the ID of the user associated with the role. |
| String | This is the rating value, an integer between 1 and 5. |
| String | This is the information about the reviewer, including ID and name. |
| String | This is the text written by the reviewer as part of the rating. |
| String | This is the time the rating was created. The time is in ISO 8601 format. |
| Object | This is the information about the pagination of the feed. It contains fields such as |
| Object | This is a summary of the feed containing information such as |
Insights
Insights on a Facebook page are tools and metrics that provide data and information about the page’s reach, engagement, and other vital metrics. Insights data is updated regularly, and data for various periods, such as the last day, week, or month, are available to view.
Insights data can be helpful for page admins, editors, and analysts in a variety of ways, such as:
Insights can show how many users are seeing the page’s content and how they are interacting with it.
Insights can help admins/other important users understand the type of content most popular with their audience/followers.
Insights can help track the page’s performance over time and identify trends and patterns in the data.
The base URL for the endpoint above is:
https://graph.facebook.com/v16.0/{page_id}/insights
Request parameters
The request parameters for the above endpoint are provided in the table below.
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received in response after making the call to the |
| String | Mandatory | This is the metric that we want in the response. For example, |
| String | Optional | This is the period over which the metric is returned. For example, |
| String | Optional | These are the fields we want in the response from the API call. |
| DateTime | Optional | This date represents the lower bound of the range to query data. This is a UNIX timestamp or ISO 8601 date. |
| DateTime | Optional | This date represents the upper bound of the range to query data. This is a UNIX timestamp or ISO 8601 date. |
| String | Optional | This specifies the maximum number of results we want in the response. |
To get insights for a Facebook page using the Facebook Graph API, we can make a GET
request to the insights
edge of the page
object using the page's ID and a page access token with the read_insights
and pages_read_engagement
permissions. Click the “Run” button to see the response.
// Importing libraries hereimport fetch from "node-fetch"// Define endpoint URL hereconst endpointUrl = new URL("https://graph.facebook.com/v16.0/{{PAGE_ID}}/insights");const headerParameters = {contentType: "application/json",};// Setting API call optionsconst options = {method: "GET",headers: headerParameters,};// Define Query Parameters hereconst queryParameters = new URLSearchParams({access_token: '{{PAGE_ACCESS_TOKEN}}',metric: 'page_impressions',limit: '10'});// Function to make API callasync function fetchPageInsights() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(error);}}// Calling function to make API callfetchPageInsights();
In the code widget above:
Line 5: We define the endpoint URL in the
endpointUrl
variable.Lines 18–22: We add the
access_token
, specify themetric
, and set thelimit
to10
to specify the maximum number of results to return in response in thequeryParameters
variable.Line 28: We use the
fetch
function to make the API call.
Response fields
The response fields for the above endpoint are mentioned in the table below.
Name | Type | Description |
| String | This is the ID of the insight. |
| String | This is the name of the metric for this insight. |
| String | This is the period over which the data was aggregated. |
| String | This is the title of the insight. |
| String | This is the description of the insight. |
| Array | This is the array of objects, and each one contains the value and `end_time` of the insight. |
| Object | This is the information about the pagination of the feed. It contains fields such as |
| Object | This is a summary of the feed containing information such as |