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


REST API

The REST API provides an interface that is called by the Social Commerce user interface widgets. This interface follows the REST style, with the REST API providing a stateless server that is organized with resources. It also provides support for readable URLs and cacheable content.

The URIs listed for each Social Commerce user interface widget must use the following prefix:

/soccom/api

For example, the following URL retrieves the result for the profileList URI request:

http://hostname/soccom/api/profilesList/john%2Cjane

By default, all request and response data uses the application/json Content-Type. All response data is wrapped in the following structure:

{
"status": { "type": "integer" }, "message": { "type": "string" }, "data": { "type": "object" }, }




The REST API uses the following status codes in response data:

Status codes
Status code Description
200 Success
404 Failure

You can obtain more detailed status codes from the status field of the response. For example, Social Commerce uses the following detailed status codes:

Detailed Social Commerce status codes
Status code Description
200 OK - Successful request
204 No Content - Successful request with no content returned
401 Unauthorized - No authenticated user found
403 Forbidden - Unsupported resource operation
500 Internal Server Error


Sorting

Sorting is implemented across services and is available for blog entries, photos, and reviews. Sorting options are passed when requesting a list, such as a list of blog entries, using the sortOptions query parameter. The value of the sortOptions parameter is a string of comma separated options that adhere to the following format:

<field name>|<direction>

Where:

field name

A valid field that is returned for the requested resource type.

direction

The direction in which to sort the list of entries. For example, to fetch and sort blog entries by date in descending order, set the value of the sortOptions parameter to date|desc. To sort by author in ascending order, and then by date in ascending order, set the query parameter to sortOptions=author|asc,date|desc. If supported by the service provider, you can provide multiple sort options.


Common formats

All date fields must adhere to the following format:

yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

The utility date format function in the SoccomUtils.js file receives the date in this format, and then converts it into a locale-specific date.

  • Profiles
    The Social Commerce Profile widget uses the REST API to retrieve and modify the information contained in a public user profile that is stored with the social content service provider.

  • 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.

  • Photo galleries
    The Social Commerce PhotoGallery widget uses the REST API to retrieve, create, and recommend content from photo galleries, photos, and comments posted for photos that is stored with the social content provider.

  • Ratings and reviews
    The Social Commerce Reviews widget uses the REST API to retrieve existing review content and create new reviews that are stored with the social content provider.

  • Search engine optimized (SEO) content
    The SEO Rest service is used by the com.ibm.commerce.soccom.seo.SeoService class. This class contains methods to embed SEO content directly into a JSP file. You can also use the REST API to return the HTML snippets that make up the SEO content.


Related tasks

Create new service adapters

Implement the Service Adapter API for new service providers


+

Search Tips   |   Advanced Search