I am developing Sharepoint hosted app, and there is a situation where i need to get the data from 4 lists simultaneously, then use it later on. I am able to do it using CSOM. But performance wise what will be better CSOM or REST API. If rest API is the better approach then how can i do it.?
2 Answers
My approach for SharePoint-hosted add-in is to use
a. REST API when requesting:
- Single Element / Single Collection retrieval (single List, single ListColletion, single ListItem, single ListItemCollection, single Field, single FieldCollection etc.)
- Large Datasets
- Two things to consider when using REST API:
- i. I do prefer using
sp.RequestExecutor.js
to executeQueryAsync over $Ajax calls. Reason #1: developing addins that interacts with other Site Collections or sibling webs. Reason #2: yourX-RequestDigest
header is resolved natively. - ii. Choose wisely your odata value in the
Accept: application/json; odata=?
header.odata=verbose
is, well, verbose, meaning that it returns A LOT of generally unuseful metadata information that slow down responses.odata=mininalmetadata
is a good choice for when you need a single metadatata information.odata=nometadata
is what you generally need. Note that the object returned varies. While in verbose mode:obj.body.d.results
. For the two other methods,obj.body.value
b. I use JSOM API when I need to:
- Request ==at once== more than one List or ListItem, or need to load into the context different elements.
- Batch updates
http://www.andrewconnell.com/blog/sharepoint-2013-csom-vs.-rest-...-my-preference-and-why
http://blog.mannsoftware.com/?p=1521
https://blogs.office.com/2014/08/13/json-light-support-rest-sharepoint-api-released/
http://www.odata.org/documentation/odata-version-2-0/overview/
https://msdn.microsoft.com/en-us/library/office/dn168907.aspx
http://www.vrdmn.com/2013/07/batch-operations-using-javascript.html

- 2,747
- 3
- 21
- 20
I invite you to read this article : http://blog.mannsoftware.com/?p=1521
In my understanding, REST shows better performance. In time response time, it's about 30% shorter.
And how to dot it ? With Ajax, it's quite easy. Here is an example which show how to use it :

- 366
- 1
- 14