Fetch Recently Viewed Products [Beta]
Fetch Products that have been recently viewed by a Shopper
Contact support for using Beta Shopper APIs.
Introduction
This API retrieves the products that are recently viewed by a shopper. For logged-in shoppers, all recently viewed are retrieved, while for non-logged-in shoppers, all recently viewed actions associated with their session on the device are retrieved. By default, the API returns a maximum of 12 recently viewed products.
Endpoint
Endpoint | request type | API Type |
---|---|---|
https://{{Swym API Endpoint}}/api/v3/shopper/fetch-recently-viewed-products | POST | shopper |
Query Params
Parameter | Type | Required | Description |
---|---|---|---|
pid | string (Encoded) | Yes | Unique identifier for the store available in Swym Admin |
Form Data
Field | Type | Required | Description |
---|---|---|---|
regid | string | Yes | Unique identifier for the shopper generated by generate-regid |
sessionid | string | Yes | Session ID generated with generate-regId endpoint which does not expire without manual intervention |
Example Curl
curl --location '{{Swym API Endpoint}}/api/v3/shopper/fetch-recently-viewed-products?pid={{URL Encoded PID}}' \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'regid={{regid}}' \
--data-urlencode 'sessionid={{sessionid}}'
Curl Placeholders
Assuming these values are provided above, the curl command should work correctly. However, if there are any issues with the API endpoint or the data being passed in the request, there could still be errors that need to be resolved before you can test these APIS.
Placeholders | Descriptions |
---|---|
{{Swym API Endpoint}} | This needs to be replaced with the actual Swym API endpoint URL. |
{{URL Encoded PID}} | This needs to be replaced with the actual PID value, URL-encoded. |
{{regid}} | This needs to be replaced with the actual regid value. |
{{sessionid}} | This needs to be replaced with the actual session ID value. |
Success Response
{
"recentlyViewed": [
{
// Number of times the product is viewed
"count": 28,
// Product ID from the Platform
"productId": 7096231231686,
// Timestamp at which the product was viewed last time
"lastViewedTime": 1709013095458,
// Varaint ID form the Platform
"variantId": 41254655393990,
// Produc URL
"productURL": "https://demo.swym.it/products/ceramic-oval-basin",
// Timestamp of the latest order placed with the product after it was viewed
"lastOrderTimestamp": 1708426159001,
// ID of the variant that was ordered after the product was viewed
"lastOrderedVariantId": 41254655393990,
// ID of the latest order placed with the product after it was viewed
"lastOrderId": 2849832
}
]
}
Error Response:
If the request is unsuccessful, the API will return a JSON response with an error message and an HTTP status code indicating the type of error that occurred.
Status Code | Type | Description |
---|---|---|
400 | Bad Request | Your request is invalid, change your request params and query and try again. |
401 | Unauthorised | You are performing an action on a resource that is not granted to the current logged-in user. Additionally, for REST APIs, this could mean your API key is wrong. |
403 | Forbidden | You are not allowed to request this data. |
404 | Not Found | The specified requested data could not be found. |
429 | Too Many Requests | You're raising too many requests! Slow down! |
500 | Internal Server Error -- | We had a problem with our server. Try again later. |
503 | Service Unavailable | We're temporarily offline for maintenance. Please try again later. |
Updated 9 months ago