Expanding Objects
In order to limit the size of the responses and the number of API calls to the server,
UltraCart supports expanding certain objects through the _expand query parameter. The best
example of expansion is the item object, because items contain a large amount of data. Often
programs want to query an item, but only a portion of it, make a change, and then update the
item. REST expansion lets you indicate how you want the object expanded beyond the basic
object on the retrieval request. This reduces the need to make additional API calls to fetch
deeper information, as most REST APIs require. Then on the update API calls, if the object is
only partially expanded, then only those portions of the object are updated, the rest of the
object that exists on the server is left alone.
Using REST expansion will:
- Make your REST API calls faster
- Reduce the bandwidth consumed by your API calls
- Provide simpler objects to work with
Each REST API that supports expansion will have the _expand parameter documented on the API
call, listing the values that call accepts. The corresponding create/update REST APIs will
handle receiving the partially expanded object without any special action on your part. For
the full list per resource, see Available expansions by resource
below.
The exact same expansion syntax used on the _expand parameter is also used in our
webhook configuration to specify the amount of expansion for the objects that
you receive notices on.
Example
Here is an example of a real-world _expand parameter from a WordPress plugin:
_expand=pricing,shipping.distribution_centers,content.multimedia.thumbnails[filter(100,100,"png", true),filter(360,360, "png", true)]
The sample expansion above tells the system that the call is interested in:
- pricing
- shipping
- distribution_centers (this contains the inventory information)
- content
- multimedia
- thumbnails (filtered to 100x100 square PNGs and 360x360 square PNGs)
- multimedia
Basic item response
{
"merchant_item_oid": 875851,
"merchant_id": "DEMO",
"merchant_item_id": "Baseball Bat",
"description": "Wood Baseball Bat",
"description_translated_text_instance_oid": 649867,
"last_modified_dts": "2016-08-11T16:14:46-04:00",
"creation_dts": "2009-01-14T18:30:42-05:00"
}
Expanded item response
{
"merchant_item_oid": 875851,
"merchant_id": "DEMO",
"merchant_item_id": "Baseball Bat",
"description": "Wood Baseball Bat",
"description_translated_text_instance_oid": 649867,
"last_modified_dts": "2016-08-11T16:14:46-04:00",
"creation_dts": "2009-01-14T18:30:42-05:00",
"pricing": {
"cost": 5.50
},
"shipping": {
"distribution_centers": [{
"distribution_center_oid": 29522,
"distribution_center_code": "DFLT",
"inventory_level": 4,
"handles": true,
"allocated_to_placed_orders": 2,
"allocated_to_shopping_carts": 0,
"available_to_allocate": 2
}]
},
"content": {
"view_url": "http://www.testajax.com/catalog/DEMO/products/facebook/fb-single/Baseball Bat.html",
"multimedia": [{
"merchant_item_multimedia_oid": 239393,
"file_name": "baseballbat.jpg",
"description": "Baseball Bat",
"url": "//secure.ultracart.com/itemmultimedia/DEMO/BASEBALL BAT/baseballbat.jpg",
"type": "Image",
"code": "default",
"width": 108,
"height": 120,
"thumbnails": [{
"height": 100,
"width": 100,
"http_url": "http://ultracartthumbs.s3.amazonaws.com/1363101689475/DEMO/0/1/100-100-01C192A2E7695865D44C6C51ECE91A29.jpg",
"https_url": "https://s3.amazonaws.com/ultracartthumbs/1363101689475/DEMO/0/1/100-100-01C192A2E7695865D44C6C51ECE91A29.jpg",
"square": true
}, {
"height": 360,
"width": 360,
"http_url": "http://ultracartthumbs.s3.amazonaws.com/1472069542543/DEMO/0/1/360-360-01C192A2E7695865D44C6C51ECE91A29.jpg",
"https_url": "https://s3.amazonaws.com/ultracartthumbs/1472069542543/DEMO/0/1/360-360-01C192A2E7695865D44C6C51ECE91A29.jpg",
"square": true
}]
}]
}
}
Available expansions by resource
Nesting is expressed with a dot, so shipping.tracking_number_details expands
tracking_number_details inside shipping. Requesting a nested value does not imply its
parent, so list each level you want.
Resources not listed here accept _expand but do not publish a value list. Check the
_expand parameter on the specific endpoint in the API reference.
Auto Orders
58 expansions.
itemsitems.future_schedulesitems.simple_schedulelogsmanagementoriginal_orderoriginal_order.affiliateoriginal_order.affiliate.ledgeroriginal_order.auto_orderoriginal_order.billingoriginal_order.buysafeoriginal_order.channel_partneroriginal_order.checkoutoriginal_order.couponoriginal_order.current_stage_historiesoriginal_order.customer_profileoriginal_order.digital_orderoriginal_order.edioriginal_order.fraud_scoreoriginal_order.giftoriginal_order.gift_certificateoriginal_order.internaloriginal_order.itemoriginal_order.linked_shipmentoriginal_order.marketingoriginal_order.paymentoriginal_order.payment.transactionoriginal_order.quoteoriginal_order.salesforceoriginal_order.shippingoriginal_order.summaryoriginal_order.taxesrebill_ordersrebill_orders.affiliaterebill_orders.affiliate.ledgerrebill_orders.auto_orderrebill_orders.billingrebill_orders.buysaferebill_orders.channel_partnerrebill_orders.checkoutrebill_orders.couponrebill_orders.customer_profilerebill_orders.digital_orderrebill_orders.edirebill_orders.fraud_scorerebill_orders.giftrebill_orders.gift_certificaterebill_orders.internalrebill_orders.itemrebill_orders.linked_shipmentrebill_orders.marketingrebill_orders.paymentrebill_orders.payment.transactionrebill_orders.quoterebill_orders.salesforcerebill_orders.shippingrebill_orders.summaryrebill_orders.taxes
Checkout
27 expansions.
affiliatebillingbuysafecheckoutcouponscustomer_profilegiftgift_certificateitemsitems.attributesitems.multimediaitems.multimedia.thumbnailsitems.physicalmarketingpaymentsettings.billing.provincessettings.giftsettings.shipping.deliver_on_datesettings.shipping.estimatessettings.shipping.provincessettings.shipping.ship_on_datesettings.taxessettings.termsshippingsummarytaxesupsell_after
Customers
14 expansions.
attachmentsbillingcardscc_emailsloyaltyorders_summarypricing_tiersprivacyquotes_summaryreviewershippingsoftware_entitlementstagstax_codes
Items
47 expansions.
accountingamemberauto_orderauto_order.stepsccbillchannel_partner_mappingschargebackcheckoutcontentcontent.assignmentscontent.attributescontent.multimediacontent.multimedia.thumbnailsdigital_deliveryebayemail_notificationsenrollment123gift_certificategoogle_product_searchidentifiersinstant_payment_notificationsinternalkit_definitionoptionspayment_processingphysicalpricingpricing.tiersrealtime_pricingrelatedreportingrestrictionrevguardreviewsreviews.individual_reviewssalesforceshippingshipping.casesshipping.destination_markupsshipping.destination_restrictionsshipping.distribution_centersshipping.methodsshipping.package_requirementstaxthird_party_email_marketingvariationswishlist_member
Orders
28 expansions.
affiliateaffiliate.ledgerauto_orderbillingbuysafechannel_partnercheckoutcouponcurrent_stage_historiescustomer_profiledigital_orderedifraud_scoregiftgift_certificateinternalitemlinked_shipmentmarketingpaymentpayment.transactionquotesalesforceshippingshipping.tracking_number_detailssummarytaxesutms