Create, Update, and Delete a Page

Overview

A blog page, also referred to as a page, contains information that is not going to be updated or changed. This commonly includes profile, business, or contact information. Blog pages are not timestamped.

Page attributes

The table below shows the complete list of properties for the page class.

Parameter

Type

Description

kind

string

The type of object.

Value: "blogger#page"

Note: This value is fixed.

id

string

The ID of the page.

blog

object

The object that contains the blog information for the page.

blog.id

string

The Blog ID for the page.

published

datetime

The page's publishing date.

Format: yyyy-mm-dd

updated

datetime

The date of page's last update.

Format: yyyy-mm-dd

url

string

The published link of the page.

selfLink

string

The Blogger API URL of the page.

title

string

The title of the page.

content

string

The content of the page.

author

object

The object that contains the author information of the page.

author.id

string

The ID of the author.

author.displayName

string

The name of the author.

author.url

string

The published link of the author profile.

author.image

object

The object that contains the author avatar information.

author.image.url

string

The URL of the author avatar.

status

string

The page status for admin resources.

Allowable values: "LIVE", "DRAFT"

Methods

We'll now look at various methods of the page class that'll enable us to create, update, and delete a blog page.

Create a page

We can create a blog page by sending a POST request to the following URL:

https://blogger.googleapis.com/v3/blogs/{blogId}/pages

As part of the request body, we'll need to provide a page object that contains the attributes given in the table above. Moreover, we'll need to specify the blogId of the blog that we would like to add the new page to.

Request parameters

Parameter

Type

Category

Description

blogId

string

required

The ID of the blog to add the page to.

Sample code

Enter the value for the required parameter blogId on line 1 in the widget below. Add values for title and content attributes as part of the request body on lines 4–5. Try adding the values for other optional parameters listed in the page attributes table above.

Click the "Run" button to see the output.

Press + to interact
blogId = ''
data = {
"title": "",
"content": ""
}
url = 'https://blogger.googleapis.com/v3/blogs/' \
+ blogId + '/pages'
response = requests.post(url, headers=headers, json=data)
printResponse(response)

The above code displays the newly created page object containing the attributes listed in the page properties table above. An appropriate error message will be displayed if the API call fails.

Update a page

In order to update a blog page, we can make a PUT request to the following URL, providing the blogId of the blog that contains the page to be updated in addition to the pageId of the page that we would like to update:

https://blogger.googleapis.com/v3/blogs/{blogId}/pages/{pageId}

Furthermore, as part of the request body, we can update any of the fields given in the page attributes table above.

Request parameters

Parameter

Type

Category

Description

blogId

string

required

The ID of the blog whose page is to be updated.

pageId

string

required

The ID of the page to be updated.

Sample code

In the code below, let's change the title of an existing page. Enter the values for the required parameters blogId and pageId on lines 1–2. Add the new value for the title attribute on line 5. Try updating any other attribute(s) listed in the page attributes table above.

Click the "Run" button to see the output.

Press + to interact
blogId = ''
pageId = ''
data = {
'title': '',
}
url = 'https://blogger.googleapis.com/v3/blogs/' \
+ blogId + '/pages/' + pageId
response = requests.put(url, headers=headers, json=data)
printResponse(response)

The above code displays the complete page object corresponding to the given pageId. This page object contains the attributes listed in the page properties table above with updated values. An appropriate error message will be displayed if the API call fails.

Delete a page

We can delete a blog page by making a DELETE request to the following URL:

https://blogger.googleapis.com/v3/blogs/{blogId}/pages/{pageId}

This endpoint requires the blogId of the blog from which we're deleting the page in addition to the pageId corresponding to the page that we would like to delete.

Request parameters

Parameter

Type

Category

Description

blogId

string

required

The ID of the blog whose page is to be deleted.

pageId

string

required

The ID of the page to be deleted.

Sample code

In the code below, enter the values for the required parameters blogId and pageId on lines 1–2.

Click the "Run" button to see the output.

Press + to interact
blogId = ''
pageId = ''
url = 'https://blogger.googleapis.com/v3/blogs/' \
+ blogId + '/pages/' + pageId
response = requests.delete(url, headers=headers)
printResponse(response)

The above code displays a success message if the page object corresponding to the given pageId is successfully deleted. An appropriate error message will be displayed if the API call fails.