Pageviews, List, and Search Pages
Learn about pageviews and how to list and search pages.
Overview
In this lesson, we'll learn how to retrieve the number of pageviews for a particular blog page over a certain period of time. We'll also learn how to retrieve a single blog page, as well as a list of all blog pages.
Pageview properties
The table below shows the list of pageview properties and their descriptions.
Parameter | Type | Description |
| string | The type of object. Value: "blogger#page_views" Note: This value is fixed. |
| long | The ID of the blog. |
| list | The list of time range and count pairs for each page. |
| string | The duration over which the count was estimated. |
| long | The number of pageviews. |
Methods
Get pageviews
We can retrieve the pageview stats for a specific blog by making a GET
request to the following endpoint:
https://blogger.googleapis.com/v3/blogs/{blogId}/pageviews
This endpoint requires the blogId
of the blog that we would like to retrieve the pageview stats for.
Request parameters
Parameter | Type | Category | Description |
| string | required | The ID of the blog whose pageview stats we want to retrieve. |
| string | optional | The duration from which to retrieve the pageview counts. Allowable values: "30DAYS", "7DAYS", "all" |
Sample code
In the code below, enter the value for the required parameter blogId
on line 1. Try adding the optional parameter, range
, to the URL on lines 3–4 to fine-tune your results.
Click the "Run" button to see the output.
blogId = ''url = 'https://blogger.googleapis.com/v3/blogs/' \+ blogId + '/pageviews'response = requests.get(url, headers=headers)printResponse(response)
The above code displays a pageview object that contains the attributes given in the pageview properties table above. An appropriate error message will be displayed if the API call fails.
List pages
We can retrieve a list of all blog pages by making a GET
request to the following URL:
https://blogger.googleapis.com/v3/blogs/{blogId}/pages
This endpoint requires the blogId
of the blog whose pages we’d like to retrieve.
Request parameters
Parameter | Type | Category | Description |
| string | required | The ID of the blog whose pages are to be retrieved. |
| boolean | optional | "True" to retrieve page bodies, "False" otherwise. |
| string | optional | The type of pages to be retrieved. Allowable values: "draft" for unpublished pages, "imported" for pages with removed content, "live" for public pages |
| string | optional | The level of details to be retrieved. Allowable values: "ADMIN", "AUTHOR", "READER" |
Sample code
In the code below, enter the value for the required parameter blogId
on line 1. Try adding the optional parameters, given in the table above, to the URL on lines 3–4 to fine-tune your results.
Click the "Run" button to see the output.
blogId = ''url = 'https://www.googleapis.com/blogger/v3/blogs/' \+ blogId + '/pages'response = requests.get(url, headers=headers)printResponse(response)
The above code displays the complete list of blog pages from the specified blog. The output contains the response parameters given in the table below. An appropriate error message will be displayed if the API call fails.
Response parameters
Parameter | Type | Description |
| string | The type of object. Value: "blogger#pageList" Note: This value is fixed. |
| list | The list of pages for the specified blog. |
Get page information
We can retrieve the information for a single blog page by making a GET
request to the following URL:
https://blogger.googleapis.com/v3/blogs/{blogId}/pages/{pageId}
This endpoint requires the blogId
of the blog that contains the page we would like to retrieve, as well as the pageId
of the page itself.
Request parameters
Parameter | Type | Category | Description |
| string | required | The ID of the blog whose page is to be retrieved. |
| string | required | The ID of the page to be retrieved. |
| string | optional | The level of details to be retrieved. Allowable values: "ADMIN", "AUTHOR", "READER" |
Sample code
In the code below, enter the value for the required parameters blogId
and pageId
on lines 1–2. Try adding the optional parameter, view
, to the URL on lines 4–5 to fine-tune your results.
Click the "Run" button to see the output.
blogId = ''pageId = ''url = 'https://www.googleapis.com/blogger/v3/blogs/' \+ blogId + '/pages/' + pageIdresponse = requests.get(url, headers=headers)printResponse(response)
The above code displays the complete page object corresponding to the given pageId
and blogId
. This page object contains the attributes listed in the page properties table given in the previous lesson. An appropriate error message will be displayed if the API call fails.