Blogger JSON API: Using the API

Important: We will discontinue support for the v2.0 JSON API on September 30th, 2024. To ensure continued functionality, update your applications that rely on the v2.0 JSON API to the latest API version. For the latest version, use the links in the left-side navbar.

This document describes how to use the common features of the Blogger JSON API using the RESTful calling style.

Contents

Introduction

This document is intended for developers who want to write applications that can interact with the Blogger JSON API. Blogger is a tool for creating websites that allow people to publish their thoughts on an ongoing basis.

If you're unfamiliar with Blogger concepts, you should read Getting Started before starting to code.

Authorizing requests and identifying your application

Every request your application sends to the Blogger JSON API needs to identify your application to Google. There are two ways to identify your application: using an OAuth 2.0 token (which also authorizes the request) and/or using the application's API key. Here's how to determine which of those options to use:

  • If the request requires authorization (such as a request for an individual's private data), then the application must provide an OAuth 2.0 token with the request. The application may also provide the API key, but it doesn't have to.
  • If the request doesn't require authorization (such as a request for public data), then the application must provide either the API key or an OAuth 2.0 token, or both—whatever option is most convenient for you.

About authorization protocols

Your application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported.

Note: The Blogger JSON API does not currently support logging in at the same time as requesting data access (hybrid) or domain-wide delegation of authority (2LO).

Authorizing requests with OAuth 2.0

Requests to the Blogger JSON API for non-public user data must be authorized by an authenticated user.

The details of the authorization process, or "flow," for OAuth 2.0 vary somewhat depending on what kind of application you're writing. The following general process applies to all application types:

  1. When you create your application, you register it with Google. Google then provides information you'll need later, such as a client ID and a client secret.
  2. Activate the Blogger JSON API in the Services pane of the Google APIs Console. (If it isn't listed in the Console, then skip this step.)
  3. When your application needs access to user data, it asks Google for a particular scope of access.
  4. Google displays an OAuth dialog to the user, asking them to authorize your application to request some of their data.
  5. If the user approves, then Google gives your application a short-lived access token.
  6. Your application requests user data, attaching the access token to the request.
  7. If Google determines that your request and the token are valid, it returns the requested data.

Some flows include additional steps, such as using refresh tokens to acquire new access tokens. For detailed information about flows for various types of applications, see Google's OAuth 2.0 documentation.

Here's the OAuth 2.0 scope information for the Blogger JSON API:

https://www.googleapis.com/auth/blogger

To request access using OAuth 2.0, your application needs the scope information, as well as information that Google supplies during application registration (such as the client ID and/or the client secret).

Tip: The Google APIs client libraries can handle some of the authorization process for you. They are available for a variety of programming languages; check the Libraries and Samples page for more details.

Acquiring and using an API key

Requests to the Blogger JSON API for public data must be accompanied by an identifier, which can be an API key or an auth token.

To acquire an API key, visit the APIs Console. In the Services pane, activate the [api_name]; if the Terms of Service appear, read and accept them.

Next, go to the API Access pane. The API key is near the bottom of that pane, in the section titled "Simple API Access."

After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.

The API key is safe for embedding in URLs; it doesn't need any encoding.

Working with Blogs

Retrieving a Blog

You can retrieve information for a particular Blogs Resource by sending an HTTP GET request to the Blog's URI. The URI for a Blogs Resource has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/2399953&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the blog data:

200 OK

{
  "kind": "blogger#blog",
  "id": "2399953",
  "name": "Blogger Buzz",
  "description": "The Official Buzz from Blogger at Google",
  "published": "2007-04-23T22:17:29.261Z",
  "updated": "2011-08-02T06:01:15.941Z",
  "url": "http://buzz.blogger.com/",
  "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953",
  "posts": {
    "totalItems": 494,
    "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts"
  },
  "pages": {
    "totalItems": 2,
    "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/pages"
  },
  "locale": {
    "language": "en",
    "country": "",
    "variant": ""
  }
}

Retrieving a User's Blogs

You can retrieve a list of a user's blogs by sending an HTTP GET request to the Blogs Collection URI:

https://www.googleapis.com/blogger/v2/users/userId/blogs

Request

Here is an example of a GET request that lists a user's blogs:

GET https://www.googleapis.com/blogger/v2/users/self/blogs
Authorization: /* OAuth 2.0 token here */

Note: The user must be authenticated to list their own blogs, so you must provide the Authorization HTTP header with the GET request.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the full representation of the list of the user's blogs:

200 OK

{
  "kind": "blogger#blogList",
  "items": [
    {
      "kind": "blogger#blog",
      "id": "4967929378133675647",
      "name": "Brett's Test Blawg",
      "description": "",
      "published": "2010-10-06T23:33:31.662Z",
      "updated": "2011-08-08T06:50:02.005Z",
      "url": "http://brettmorgan-test-blawg.blogspot.com/",
      "selfLink": "https://www.googleapis.com/blogger/v2/blogs/4967929378133675647",
      "posts": {
        "totalItems": 13,
        "selfLink": "https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/posts"
      },
      "pages": {
        "totalItems": 1,
        "selfLink": "https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/pages"
      },
      "locale": {
        "language": "en",
        "country": "",
        "variant": ""
      }
    }
  ]
}

Working with Posts

Retrieving Posts from a Blog

You can retrieve a list of Posts from a given Blog by sending a GET request to the Posts Collection URI. The URI for a Posts Collection has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/posts

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/2399953/posts&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Posts from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the list of Posts:

200 OK

{
  "kind": "blogger#postList",
  "nextPageToken": "CgkIChiAkceVjiYQ0b2SAQ",
  "prevPageToken": "CgkIChDBwrK3mCYQ0b2SAQ",
  "items": [
    {
      "kind": "blogger#post",
      "id": "7706273476706534553",
      "blog": {
        "id": "2399953"
      },
      "published": "2011-08-01T19:58:00.000Z",
      "updated": "2011-08-01T19:58:51.947Z",
      "url": "http://buzz.blogger.com/2011/08/latest-updates-august-1st.html",
      "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/7706273476706534553",
      "title": "Latest updates, August 1st",
      "content": "elided for readability",
      "author": {
        "id": "401465483996",
        "displayName": "Brett Wiltshire",
        "url": "http://www.blogger.com/profile/01430672582309320414",
        "image": {
          "url": "http://4.bp.blogspot.com/_YA50adQ-7vQ/S1gfR_6ufpI/AAAAAAAAAAk/1ErJGgRWZDg/S45/brett.png"
         }
      },
      "replies": {
        "totalItems": "0",
        "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/7706273476706534553/comments"
      }
    },
    {
      "kind": "blogger#post",
      "id": "6069922188027612413",
      elided for readability
    }
  ]
}

Retrieving a Specific Post

You can retrieve a specific Post from a Blog by sending a GET request to the Posts Resource URI. The URI for a Posts Resource has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/posts/postId

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/2399953/posts/7706273476706534553&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Posts from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the contents of the Post:

200 OK

{
  "kind": "blogger#post",
  "id": "7706273476706534553",
  "blog": {
    "id": "2399953"
  },
  "published": "2011-08-01T19:58:00.000Z",
  "updated": "2011-08-01T19:58:51.947Z",
  "url": "http://buzz.blogger.com/2011/08/latest-updates-august-1st.html",
  "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/7706273476706534553",
  "title": "Latest updates, August 1st",
  "content": "elided for readability",
  "author": {
    "id": "401465483996",
    "displayName": "Brett Wiltshire",
    "url": "http://www.blogger.com/profile/01430672582309320414",
    "image": {
      "url": "http://4.bp.blogspot.com/_YA50adQ-7vQ/S1gfR_6ufpI/AAAAAAAAAAk/1ErJGgRWZDg/S45/brett.png"
    }
  },
  "replies": {
    "totalItems": "0",
    "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/7706273476706534553/comments"
  }
}

Working with Comments

Retrieving Comments for a Post

You can retrieve a list of Comments for a Post by sending a GET request to the Comments Collection URI. The URI for a Comments Collection has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/posts/postId/comments

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/2399953/posts/6069922188027612413/comments&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Comments from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the list of comments:

200 OK

{
  "kind": "blogger#commentList",
  "nextPageToken": "CgkIFBDwjvDXlyYQ0b2SARj9mZe9n8KsnlQ",
  "prevPageToken": "CgkIFBisvMGRlyYQ0b2SARj9mZe9n8KsnlQ",
  "items": [
    {
       "kind": "blogger#comment",
       "id": "9200761938824362519",
       "post": {
         "id": "6069922188027612413"
       },
       "blog": {
         "id": "2399953"
       },
       "published": "2011-07-28T19:19:57.740Z",
       "updated": "2011-07-28T21:29:42.015Z",
       "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/6069922188027612413/comments/9200761938824362519",
       "content": "elided",
       "author": {
         "id": "530579030283",
         "displayName": "elided",
         "url": "elided",
         "image": {
           "url": "elided"
         }
       }
    },
    {
      "kind": "blogger#comment",
      "id": "400101178920857170",
      elided for readability
    }
  ]
}

Retrieving a Specific Comment

You can retrieve a specific Comment from a Post by sending a GET request to the Comments Resource URI. The URI for a Comments Resource has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/posts/postId/comments/commentId

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/2399953/posts/6069922188027612413/comments/9200761938824362519&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Comments from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the comment data:

200 OK

{
  "kind": "blogger#comment",
  "id": "9200761938824362519",
  "post": {
    "id": "6069922188027612413"
  },
  "blog": {
    "id": "2399953"
  },
  "published": "2011-07-28T19:19:57.740Z",
  "updated": "2011-07-28T21:29:42.015Z",
  "selfLink": "https://www.googleapis.com/blogger/v2/blogs/2399953/posts/6069922188027612413/comments/9200761938824362519",
  "content": "elided",
  "author": {
    "id": "530579030283",
    "displayName": "elided",
    "url": "elided",
    "image": {
      "url": "elided"
    }
  }
}

Working with Pages

Retrieving Pages for a Blog

You can retrieve a list of Pages for a Blog by sending a GET request to the Pages Collection URI. The URI for a Pages Collection has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/pages

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/pages&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Pages from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the list of Pages:

200 OK

{
  "kind": "blogger#pageList",
  "items": [
    {
      "kind": "blogger#page",
      "id": "273541696466681878",
      "blog": {
        "id": "4967929378133675647"
      },
      "published": "2011-07-14T16:16:00.000Z",
      "updated": "2011-07-14T16:16:23.602Z",
      "url": "http://brettmorgan-test-blawg.blogspot.com/p/static-content.html",
      "selfLink": "https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/pages/273541696466681878",
      "title": "Static Content",
      "content": "elided for readability",
      "author": {
        "id": "901569848744",
        "displayName": "brett",
        "url": "http://www.blogger.com/profile/16258312240222542576",
        "image": {
          "url": "https://resources.blogblog.com/img/b16-rounded.gif"
        }
      }
    }
  ]
}

Retrieving a Specific Page

You can retrieve a specific Page from a Blog by sending a GET request to the Pages Resource URI. The URI for a Pages Resource has the following format:

https://www.googleapis.com/blogger/v2/blogs/blogId/pages/pageId

Request

Here is an example:

GET https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/pages/273541696466681878&key=YOUR-API-KEY

Since a user does not have to be authenticated to retrieve the Pages from a public Blog, you don't have to provide the Authorization HTTP header with this GET request; but if you don't provide that header, then you do need to provide an API key.

Blogger also has private Blogs, which do require authentication.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and the page data:

200 OK

{
  "kind": "blogger#page",
  "id": "273541696466681878",
  "blog": {
    "id": "4967929378133675647"
  },
  "published": "2011-07-14T16:16:00.000Z",
  "updated": "2011-07-14T16:16:23.602Z",
  "url": "http://brettmorgan-test-blawg.blogspot.com/p/static-content.html",
  "selfLink": "https://www.googleapis.com/blogger/v2/blogs/4967929378133675647/pages/273541696466681878",
  "title": "Static Content",
  "content": "elided for readability",
  "author": {
    "id": "901569848744",
    "displayName": "brett",
    "url": "http://www.blogger.com/profile/16258312240222542576",
    "image": {
      "url": "https://resources.blogblog.com/img/b16-rounded.gif"
    }
  }
}

Working with Users

Retrieving a User

You can retrieve a user's information by sending an HTTP GET request to the Users Resource URI:

https://www.googleapis.com/blogger/v2/users/userId

Request

Here is an example of a GET request that lists a user's blogs:

GET https://www.googleapis.com/blogger/v2/users/self
Authorization: /* OAuth 2.0 token here */

Note: The user must be authenticated to list their own information, so you must provide the Authorization HTTP header with the GET request.

Response

If the request succeeds, the server responds with an HTTP 200 OK status code and a link to a list of the user's blogs:

200 OK

{
  "kind": "blogger#user",
  "id": "901569848744",
  "selfLink": "https://www.googleapis.com/blogger/v2/users/901569848744",
  "blogs": {
    "selfLink": "https://www.googleapis.com/blogger/v2/users/901569848744/blogs"
  }
}

Standard query parameters

The following query parameters can be used with all methods and all resources in the Blogger APIs.

Query parameters that apply to all Blogger APIs operations are documented at System Parameters.