Posts: search

Searches for a post that matches the given query terms. Try it now or see an example.

Authorization will be required if the blog being searched is private.

Request

HTTP request

GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/search

Parameters

Parameter name Value Description
Required parameters
blogId string The ID of the blog to search in.
q string Query terms to search for.
Optional parameters
fetchBodies boolean Whether the body content of posts is included. To minimize traffic, set this parameter to false when the post's body content is not required. (Default: true)
orderBy string The sort order applied to the search results.

Acceptable values are:
  • "published": Order by the date the post was published
  • "updated": Order by the date the post was last updated

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "kind": "blogger#postList",
  "nextPageToken": string,
  "items": [
    posts Resource
  ]
}
Property name Value Description Notes
kind string The kind of this entity. Always blogger#postList
nextPageToken string Pagination token to fetch the next page, if one exists.
items[] list The list of Posts for this Blog.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library

// The BlogId for the http://buzz.blogger.com/ blog.
String BUZZ_BLOG_ID = "2399953";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// Configure the Installed App OAuth2 flow.
Credential credential = OAuth2Native.authorize(HTTP_TRANSPORT,
JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(BloggerScopes.BLOGGER));
// Construct the Blogger API access facade object.
Blogger blogger = Blogger.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Blogger-PostsSearch-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
Search postsSearchAction = blogger.posts().search(BUZZ_BLOG_ID);
postsSearchAction.setQ("threaded comments");
// Restrict the result content to just the data we need.
postsSearchAction.setFields("items(content,published,title,url)");
// This step sends the request to the server.
PostList posts = postsSearchAction.execute();
// Now we can navigate the response.
if (posts.getItems() != null && !posts.getItems().isEmpty()) {
for (Post post : posts.getItems()) {
System.out.println("Title: " + post.getTitle());
System.out.println("Published: " + post.getPublished());
System.out.println("URL: " + post.getUrl());
System.out.println("Content: " + post.getContent());
}
}

Try it!

Use the APIs Explorer below to call this method on live data and see the response.