Fetch Lists

Fetch all lists for a shopper.

swat.fetchLists

For logged-in users, the API retrieves all List associated with their email. For guest users, it returns all Lists created during the current session, linked to their device ID.

Definition

swat.fetchLists(callbacksObj)

Example

Here's an example of how you can use this API to fetch all the Lists created :

// Define success callback
let onSuccess = function(lists) {
  // Successfully fetched all lists 
  console.log("Fetched all Lists", lists);
}

// Define error callback
let onError = function(error) {
  // Error is an xhrObject
  console.log("Error while fetching all Lists", error);
}

// Call `fetchLists` function
swat.fetchLists({
  callbackFn: onSuccess,
  errorFn: onError
});

API Parameters

ArgumentTypeDescription
onSuccessfunctionCalled when all the Lists are successfully fetched.
onErrorfunctionCalled when there is an error while fetching all the Lists.

Success Response

The success response contains an array of Lists created by the shopper. Each List has information like its name, type, lid, created timestamp (cts), and other useful metadata.

This information can be used to retrieve or manipulate the Lists in future API calls.

[{
	// Unique identifier for the device.
	"di": "-8f26-4ab3-ae35-bafd7c8eed95",
	// List of items in the list
	"listcontents": [{
		// Unique identifier for the device, 
		"di": "e502694b-8f26-4ab3-ae35-bafd7c8eed95", // De
		// Collections name
		"bt": "Swym Marketing",
		// Title of the product
		"dt": "12 Inches Round Rose Gold Frame Wall Mirror",
		// created Timestamp of when the item was added to the list
		"cts": 1679469250932,
		// Unique identifier for the user who added the item
		"empi": 7096437407942,
		// may not be applicable Stock Keeping Unit (SKU) of the item
		"sku": "45",
		// Unique identifier for the list that the item belongs to
		"lid": "a5decd55-5bfe-4cd4-9991-ed5721ae2914",
		// URL of the item's page on the website
		"du": "https://demo.swym.it/products/12-inches-round-rose-gold-frame-wall-mirror?variant=41255230701766",
		// Hashed product ID of the item
		"pid": "/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
		// Variant ID of the item
		"epi": 41255230701766,
		// Unique identifier for the item
		"id": "902d434b-92c5-445a-ad43-4b92c5245adb",
		// Timestamp of when the item was last updated
		"uts": 1679469250932,
		"_pkey": "e502694b",// Internal usage key - please ignore.
		// URL of the item's image
		"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/12InchesRoundRoseGoldFrameWallMirror_620x620.jpg?v=1637593774",
		"_t": 2, // Internal usage- please ignore.
		// User who last modified the item
		"uby": null,
		// Price of the item
		"pr": 200.0
	}],
	// Information about the user who created the list
	"userinfo": null,
	// Type of the list (in this case, "wl" means it is a wishlist)
	"lty": "wl",
	// Timestamp of when the list was created
	"cts": 1679469250670,
	// Number of items in the list
	"cnt": 1,
	// Name of the list
	"lname": "my black friday list",
	// User who created the list
	"cby": null,
	// Unique identifier for the list
	"lid": "a5decd55-5bfe-4cd4-9991-ed5721ae2914",
	// Unique merchant Id
	"pid": "KABSbuGyYCuM6/IV7e7cGxT1978Lie",
  // Updated timestamp on when the list was updated.
  "uts": 1679469250670,
  // User email id of the list. 
   "uby": null, // 
}]

📘

Cached Responses

This API has a local cache that lasts for 5 minutes. A new network request will only be sent if the cached information is no longer valid.

Other References

List Fields

{
  "lid": "swym generated list ID",
  "lname": "List name. List names need not be unique, i.e. If uniqueness is needed API caller should ensure dupes are not",
  "lty": "_recommends", //To prevent mixing with enduser created wishlists
  "lnote": "Optional. List note, single line of note at the list level",
  "lprops": {}, //Optional. Map or properties - {}. Not available downstream for reporting or segmentation queries
  "anonRead": "Optional. Default - false. Boolean flag if anonymous read is allowed for the given List ID",
  "cnt": 0,
  "_cp": false,
  "cby": "Created by email address",
  "uby": "Updated by email address",
  "cts": "Created at in milliseconds",
  "uts": "Updated at in milliseconds",
  "userinfo": {}
}
ArgumentTyperequired?Description
lidstringYesList id to identify the list uniquely.
lnamestringYesList name.
listcontentsarrayN/APreview array of list items.
ltystring(optional)List type - when null, it represents wishlist. When set to a value eg: _saveForLater, gets added to a different type of list separate from the wishlist
lnote string(optional)Optional note
lpropsobject(optional)Optional. Map of custom fields
anonReadboolean(optional)Optional. True if the list can be read anonymously with lid
cntnumberNumber of items in list
_cpboolean(optional)Optional. True if list duplication is in progress, copying the list items for large lists
ctsnumber(optional)Created time at in milliseconds
uts (optional)number(optional)Last updated time at in milliseconds
cby
(optional)
string(optional)Email address of the user if known when list was created
uby
(optional)
string(optional)Email address of the user if known when list was last updated
userinfo
(optional)
object(optional)User info of the list owner if user is known
userinfo.emstring(optional)Email address of the owner
userinfo.fnamestring(optional)First name of the owner
userinfo.lnamestring(optional)Last name of the owner