What is Sitecore.Services.Client?

Sitecore.Services.Client is a new offering found in Sitecore 7.5/8. But what is it? I had no idea so I began by reading the Developer’s Guide on the Sitecore SDN. After reading, I was definitely a bit confused since some of the functionality found in Sitecore.Services.Client seems to overlap with the functionality from the Sitecore Item Web API (Both allow you to perform basic CRUD operations on Sitecore items via web requests). While I do believe that there is some significant overlap between the two technologies, it is becoming clear to me that Sitecore.Services.Client offers a lot of new functionality that falls outside the scope of the Sitecore Item Web API.

To start, let’s define the functionality of the Sitecore Item Web API.

The Sitecore Item Web API provides access to a REST-style web service that enables external applications to retrieve and manipulate Sitecore content via JSON output.

Next, I’m going to steal the definition of Sitecore.Services.Client from the developer’s guide.

Sitecore.Services.Client provides a service layer on both the server and the client side of Sitecore applications that you use to develop data-driven applications.

Honestly, I have no idea what that means. But as I continued to read the documentation, I started to get an understanding of what type of functionality is offered by Sitecore.Services.Client.

Functionality Breakdown

Sitecore.Services.Client can be used in three different ways:

  1. From SPEAK components.
  2. From client-side JavaScript.
  3. From the Restful API directly. (Similar to Sitecore Item Web API)

And Sitecore.Services.Client provides two services:

  1. ItemService: this service gives you access to regular Sitecore items. (Similar to Sitecore Item Web API)
  2. EntityService: this service gives you access to business objects that you define.

Basically, the info above means that you can access the ItemService or the EntityService from SPEAK components, from client-side JavaScript, or from the Restful API.

So what’s new?

  • SPEAK is a massive part of the new Sitecore platform so it’s great to see some tight integration between SPEAK and Sitecore.Services.Client.
  • The EntityService provides a way for you to implement and have access to abstract business objects (That’s sort of new). You can always create your own custom web services to tackle unique problems like this but I like the idea of handling this in Sitecore.Services.Client so that some of the repetitive, heavy-lifting is taken care of for you. Let’s face it, custom web services always take more time than you expect.
  • Honestly, I’m not sure that the client-side JavaScript access is a new concept (I thought you could do this with the Item Web API – please correct me if I’m wrong) but it’s great to see lots of documentation surrounding this feature. I think it will be heavily used!

Comparison to the Sitecore Item Web API

OK, so I’ve highlighted that some of the functionality from Sitecore.Services.Client listed above seems to overlap (at least from a high level) with the Sitecore Item Web API. Let’s take a quick look at an example that compares how to request a Sitecore item with both technologies.

Sitecore Item Web API

Get Request:

http://HOST_NAME/-/item/v1/?sc_itemid=110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9

JSON Response:


{
   "statusCode":200,
   "result":{
      "totalCount":1,
      "resultCount":1,
      "items":[
         {
            "Category":"Content",
            "Database":"web",
            "DisplayName":"Home",
            "HasChildren":false,
            "Icon":"/temp/IconCache/Network/16x16/home.png",
            "ID":"{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}",
            "Language":"en",
            "LongID":"/{11111111-1111-1111-1111-111111111111}/{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}",
            "MediaUrl":"/~/icon/Network/48x48/home.png.aspx",
            "Name":"Home",
            "Path":"/sitecore/content/Home",
            "Template":"Sample/Sample Item",
            "TemplateId":"{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}",
            "TemplateName":"Sample Item",
            "Url":"~/link.aspx?_id=110D559FDEA542EA9C1C8A5DF7E70EF9\u0026amp;_z=z",
            "Version":1,
            "Fields":{
               "{75577384-3C97-45DA-A847-81B00500E250}":{
                  "Name":"Title",
                  "Type":"text",
                  "Value":"Sitecore Experience Platform"
               },
               "{A60ACD61-A6DB-4182-8329-C957982CEC74}":{
                  "Name":"Text",
                  "Type":"Rich Text",
                  "Value":"\u003cp style=\"line-height: 22px;\"\u003eFrom a single connected platform that also integrates with other customer-facing platforms, to a single view of the customer in a big data marketing repository, to a completely eliminating much of the complexity that has previously held marketers back, the latest version of Sitecore makes customer experience highly achievable. Learn how the latest version of Sitecore gives marketers the complete data, integrated tools, and automation capabilities to engage customers throughout an iterative lifecycle \u0026ndash; the technology foundation absolutely necessary to win customers for life.\u003c/p\u003e\n\u003cp\u003eFor further information, please go to the \u003ca href=\"https://doc.sitecore.net/\" target=\"_blank\" title=\"Sitecore Documentation site\"\u003eSitecore Documentation site\u003c/a\u003e\u003c/p\u003e"
               }
            }
         }
      ]
   }
}

Sitecore.Services.Client

Get Request:

https://HOST_NAME/sitecore/api/ssc/item/110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9

JSON Response:


{
   "ItemID":"110d559f-dea5-42ea-9c1c-8a5df7e70ef9",
   "ItemName":"Home",
   "ItemPath":"/sitecore/content/Home",
   "ParentID":"0de95ae4-41ab-4d01-9eb0-67441b7c2450",
   "TemplateID":"76036f5e-cbce-46d1-af0a-4143f9b557aa",
   "TemplateName":"Sample Item",
   "CloneSource":null,
   "ItemLanguage":"en",
   "ItemVersion":"1",
   "DisplayName":"Home",
   "HasChildren":"False",
   "ItemIcon":"/temp/IconCache/Network/16x16/home.png",
   "ItemMedialUrl":"/~/icon/Network/48x48/home.png.aspx",
   "ItemUrl":"~/link.aspx?_id=110D559FDEA542EA9C1C8A5DF7E70EF9&_z=z",
   "Title":"Sitecore Experience Platform",
   "Text":"<p style=\"line-height: 22px;\">From a single connected platform that also integrates with other customer-facing platforms, to a single view of the customer in a big data marketing repository, to a completely eliminating much of the complexity that has previously held marketers back, the latest version of Sitecore makes customer experience highly achievable. Learn how the latest version of Sitecore gives marketers the complete data, integrated tools, and automation capabilities to engage customers throughout an iterative lifecycle &ndash; the technology foundation absolutely necessary to win customers for life.</p>\n<p>For further information, please go to the <a href=\"https://doc.sitecore.net/\" target=\"_blank\" title=\"Sitecore Documentation site\">Sitecore Documentation site</a></p>"
}

Just a quick note about documentation – In addition to the Sitecore.Services.Client developer’s guide on the SDN, @Sobek1985 pointed me to a critical resource for the ItemService API that shows examples of various API calls.

http://docs.itemserviceapi.apiary.io/

In Closing

While there is a conceptual overlap between the functionality in Sitecore.Services.Client and the Sitecore Item Web API, they are still significantly different and you may find that one technology fits your needs more than another. I’ve been a big fan of the Sitecore Item Web API for a long time (I love the idea of setting the content free) but I’m pretty excited to see how Sitecore.Services.Client evolves in upcoming versions of Sitecore since it has a lot of potential.

So is Sitecore.Services.Client going to be the next generation of the Sitecore Item Web API? I think it can be just that (at some point in the future). It just needs a better name than Sitecore.Services.Client 😉

Thanks to @Sobek1985 and @KevinObee for the help!

Advertisements
Posted in Sitecore
One comment on “What is Sitecore.Services.Client?
  1. […] To update a Sitecore item we will use Sitecore.Services.Client. Thanks to Kevin Obee’s great “living” documentation, http://docs.itemserviceapi.apiary.io, he made it so much easier to understand how it works. There is also a great post that describes the differences between Sitecore Item Web API and Sitecore.Services.Client – What is Sitecore.Services.Client? […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s