Ratings and Insights

Learn how to get a page's ratings and insights.

View ratings

Page ratings
Page 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

access_token

String

Mandatory

This is the token that we received in response after making the call to the accounts edge of the `user` object.

summary

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.

limit

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.

Press + to interact
// Importing libraries here
import fetch from "node-fetch"
// Define endpoint URL here
const endpointUrl = new URL("https://graph.facebook.com/v16.0/{{PAGE_ID}}/ratings");
const headerParameters = {
contentType: "application/json",
};
// Setting API call options
const options = {
method: "GET",
headers: headerParameters,
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
access_token: '{{PAGE_ACCESS_TOKEN}}',
limit: '10'
});
// Function to make API call
async function fetchPageRatings() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
fetchPageRatings();

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 the limit to 10 to specify the maximum number of results to return in response in the queryParameters 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

id

String

This is the ID of the user associated with the role.

rating

String

This is the rating value, an integer between 1 and 5.

reviewer

String

This is the information about the reviewer, including ID and name.

reviewer_text

String

This is the text written by the reviewer as part of the rating.

created_time

String

This is the time the rating was created. The time is in ISO 8601 format.

paging

Object

This is the information about the pagination of the feed. It contains fields such as next and previous, which we can use to retrieve the next and previous pages of the feed, respectively.

summary

Object

This is a summary of the feed containing information such as total_count (number of total posts in the feed) and can_like (indicating whether or not the feed can be liked).

Insights

Page insights
Page 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

access_token

String

Mandatory

This is the token that we received in response after making the call to the accounts edge of the `user` object.

metric

String

Mandatory

This is the metric that we want in the response. For example, page_impressions, page_engagements, page_fans, and so on.

period

String

Optional

This is the period over which the metric is returned. For example, day, week, days_28, and so on.

fields

String

Optional

These are the fields we want in the response from the API call.

since

DateTime

Optional

This date represents the lower bound of the range to query data. This is a UNIX timestamp or ISO 8601 date.

until

DateTime

Optional

This date represents the upper bound of the range to query data. This is a UNIX timestamp or ISO 8601 date.

limit

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.

Press + to interact
// Importing libraries here
import fetch from "node-fetch"
// Define endpoint URL here
const endpointUrl = new URL("https://graph.facebook.com/v16.0/{{PAGE_ID}}/insights");
const headerParameters = {
contentType: "application/json",
};
// Setting API call options
const options = {
method: "GET",
headers: headerParameters,
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
access_token: '{{PAGE_ACCESS_TOKEN}}',
metric: 'page_impressions',
limit: '10'
});
// Function to make API call
async function fetchPageInsights() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
fetchPageInsights();

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 the metric, and set the limit to 10 to specify the maximum number of results to return in response in the queryParameters 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

id

String

This is the ID of the insight.

name

String

This is the name of the metric for this insight.

period

String

This is the period over which the data was aggregated.

title

String

This is the title of the insight.

description

String

This is the description of the insight.

values

Array

This is the array of objects, and each one contains the value and `end_time` of the insight.

paging

Object

This is the information about the pagination of the feed. It contains fields such as next and previous, which we can use to retrieve the next and previous pages of the feed, respectively.

summary

Object

This is a summary of the feed containing information such as total_count (number of total posts in the feed) and can_like (indicating whether or not the feed can be liked).