Samples > Starter stores > Starter store enhancements > Social Commerce > WebSphere Commerce Dojo Enhancements API > Social Commerce services > REST API


Blogs

The Social Commerce Blog widget uses the REST API to retrieve, create, and recommend content from blogs, blog entries, and comments posted for blog entries that is stored with the social content provider.

The Blog widget uses the following methods:

GET

Used to retrieve content from blogs, blog entries, and comments posted for blog entries.

POST

Used to create new blog entries and blog entry comments.

PUT

Used to recommend a blog entry or flag a blog entry as inappropriate.

DELETE

Used to delete a blog entry.

REST API for Blog widget
HTTP method URI Description Data type Query parameters Authenticated user
GET /blogs/<blogId> Retrieves a blog with a page of entries. blog

  • pageSize

  • onPage

  • sortOptions

 
POST /blogs/<blogId>/entries Creates a new blog entry. entry    
GET /users/<userId>/entries Retrieves a page of blog entries created by the user. entryPage

  • pageSize

  • onPage

  • sortOptions

GET /blogs/<blogId>/entries/<entryId> Retrieves an entry from a blog. entry    
PUT /blogs/<blogId>/entries/<entryId> Either recommends a blog entry or reports an entry as inappropriate. One of the following:

  • recommendation

  • inappropriate

 
DELETE /blogs/<blogId>/entries/<entryId> Deletes a blog entry. Only valid for the user who created the entry.    
POST /blogs/<blogId>/entries/<entryId>/comments Creates a new comment for a blog entry. comment  
GET /blogs/<blogId>/entries/<entryId>/comments Retrieves a page of blog entry comments. commentPage

  • pageSize

  • onPage

 
GET /blogs/<blogId>/entries/<entryId>/comments/<commentsId> Retrieves a single blog entry comment. comment    


Data types

The following table lists the data types contained in the REST API for the Blog widget and provides a code snippet to illustrate each data type.
Data type Example
blog

{
    "id":{ "type": "string" },     "title":{ "type": "string" },     "onPage":{ "type": "integer" },     "pageSize":{ "type": "integer" },     "numEntries":{ "type": "integer" },     "entries":{ "type": "array", "arrayType": "entry" }
}

entry

{
    "id":{ "type": "string" },     "blogHandle": { "type": "string" }, // Optional - usually only specified when fetching by username
    "title":{ "type": "string" },     "body":{ "type": "string" },     "date":{ "type": "date" },     "numComments":{ "type": "integer" },     "numRecommendations":{ "type": "integer" },     "authorId":{ "type": "string" },     "tags":{ "type": "array", "arrayType": "string" }
}

entryPage

{
    "onPage":{ "type": "integer" },     "pageSize":{ "type": "integer" },     "numEntries":{ "type": "integer" },     "entries":{ "type": "array", "arrayType": "entry" }
}

recommendation

{
    "recommend": { "type": "boolean" },     "action":"recommend"
}

inappropriate

{
    "inappropriate": { "type": "boolean" },     "action":"reportInappropriate"
}

comment

{
    "id":{ "type": "string" },     "authorId":{ "type": "string" },     "datePosted": { "type": "string" },     "body":{ "type": "string" }
}

commentPage

{
    "blogId":{ "type": "string" },     "entryId":{ "type": "string" },     "pageSize":{ "type": "integer" },     "onPage":{ "type": "integer" },     "numComments":{ "type": "integer" },     "comments":{ "type": "array", "arrayType": "comment" }
}


Query parameters

The following table lists and describes each of the query parameters contained in the REST API for the Blog widget.
Name Type Range Description
pageSize integer [1,infinity) The number of blog entries or comments to return.
onPage integer [1,infinity) The starting page index of blog entries or comments to return. For example, when the pageSize is set to 10 and the onPage value is set to 3, the request returns blog entries 30 through 39.
sortOptions string   The sorting options to use when retrieving blog entries or comments. The following values are supported:

date|asc

Sort by date in ascending order.

date|desc

Sort by date in descending order.

Related reference

Profiles

Photo galleries

Ratings and reviews

Search engine optimized (SEO) content

REST API


+

Search Tips   |   Advanced Search