-
Notifications
You must be signed in to change notification settings - Fork 15
What is a Partial Response?
Greg Whitaker edited this page Aug 1, 2016
·
6 revisions
By default, the server will send back the full representation of a rest resource for every request. Partial responses let you request only the elements you are interested in, instead of the full resource representation. This allows your client application to avoid transferring, parsing, and storing unneeded fields, so you can utilize network and memory resources more efficiently.
For example, take the two responses below. Both are requests for the same resource, but let's assume we are only interested in the following fields:
- Product Name
- List Price
- Image Url for Thumbnail Images Only
###Full Resource Representation http://domain/product/12345/details
{
"id": "12345",
"name": "Product 1",
"prices": {
"listPrice": "$120.00",
"salePrice: "$89.99"
},
images: [
{
"sortOrder": 1,
"url": "http://domain/images/product/12345/primary.png",
"alt": "Product 1",
"size": "primary"
},
{
"sortOrder": 2,
"url": "http://domain/images/product/12345/thumbnail.png",
"alt": "Product 1",
"size": "thumbnail"
}
]
}
###Partial Resource Representation http://domain/product/12345/details?fields=name,prices(listPrice),images(url)[size=thumbnail]
{
"name": "Product 1",
"prices": {
"listPrice": "$120.00",
},
images: [
{
"url": "http://domain/images/product/12345/thumbnail.png",
}
]
}