Create & save a custom product view
Introduction
While the ability to using a view on the fly can be useful, we do understand there are use cases that call for a specific view as a requirement. This guide will show you how to create and use a custom product view.
Creating your custom product view
For this example we will be creating a customer product view. The same methodology can be applied to any data type however. Please reference your data types schema for the fields your can use to create a custom view.
We will use the https://api.datafiniti.co/v4/views API endpoint to create this view. We will use the following top level product fields to create a view that only provides these fields upon an API search/enrichment/suppression request.
- brand
- colors
- gtins
- manufacturerNumber
- mostRecentPriceAmount
- mostRecentPriceNonSalesAmount
- mostRecentPriceDate
- prices - amountMin, amountMax, availability, isSale, offer, sourceURLs
This what the JSON for the API request should look like:
{
"name": "custom_product_view",
"data_type": "product",
"fields": [
{"name": "brand"},
{"name": "colors"},
{"name": "gtins"},
{"name": "manufacturerNumber"},
{"name": "mostRecentPriceAmount"},
{"name": "mostRecentPriceNonSalesAmount"},
{"name": "mostRecentPriceDate"},
{"name": "prices","flatten": true, "sub_fields": [
{"name": "amountMin"},
{"name": "amountMax"},
{"name": "availability"},
{"name": "isSale"},
{"name": "offer"},
{"name": "sourceURLs"}
]
}
]
}
Nested fields
Please note that if you use a top level field with nested sub fields that you will have to declare if you wish to flatten the results. Otherwise flatten is set to false by default.
Once you send the request is sent, if successful you will receive a Json 201 response like the following
{
"name": "custom_product_view",
"data_type": "product",
"fields": [
{
"flatten": false,
"sub_fields": [],
"name": "brand"
},
{
"flatten": false,
"sub_fields": [],
"name": "colors"
},
{
"flatten": false,
"sub_fields": [],
"name": "gtins"
},
{
"flatten": false,
"sub_fields": [],
"name": "manufacturerNumber"
},
{
"flatten": false,
"sub_fields": [],
"name": "mostRecentPriceAmount"
},
{
"flatten": false,
"sub_fields": [],
"name": "mostRecentPriceNonSalesAmount"
},
{
"flatten": false,
"sub_fields": [],
"name": "mostRecentPriceDate"
},
{
"flatten": true,
"sub_fields": [
{
"name": "amountMin"
},
{
"name": "amountMax"
},
{
"name": "availability"
},
{
"name": "isSale"
},
{
"name": "offer"
},
{
"name": "sourceURLs"
}
],
"name": "prices"
}
],
"user": 126609,
"date_created": "2023-09-18T19:57:52.342Z",
"date_updated": "2023-09-18T19:57:52.342Z",
"_id": 1414,
"isDynamic": false,
"id": "1414"
}
Using your custom view
Now that you have a customer view, lets use it! This can be done by declaring the view in the body of any search/pagination API call. We will use a product search API call for this example.
{
"query": "categories:(*women* AND *clothing*) AND features.key:*material* AND features.value:*leather*",
"num_records":10,
"view":"custom_product_view"
}
Here is a sample of what a record the custom_product_view
view looks like:
{
"brand": "Buxton",
"colors": [
"Olive",
"Green"
],
"gtins": [
"0043345158647",
"043345158647"
],
"manufacturerNumber": "EX91423-OL",
"prices": [
{
"amountMin": 34.99,
"amountMax": 34.99,
"availability": "true",
"sourceURLs": [
"https://www.newegg.com/buxton-ex91423-laptop-bags-olive/p/03V-008V-000C9"
]
},
{
"amountMin": 68,
"amountMax": 68,
"availability": "false",
"isSale": "false",
"sourceURLs": [
"https://www.macys.com/shop/product/expedition-ii-huntington-gear-fold-over-backpack?ID=7241789&CategoryID=45016",
"https://www.macys.com/shop/product/expedition-ii-huntington-gear-fold-over-backpack?ID=7241789&CategoryID=197651"
]
},
{
"amountMin": 33.99,
"amountMax": 33.99,
"availability": "true",
"sourceURLs": [
"https://www.newegg.com/buxton-ex91423-laptop-bags-olive/p/03V-008V-000C9"
]
},
{
"amountMin": 39.99,
"amountMax": 39.99,
"availability": "true",
"isSale": "false",
"offer": "Online only",
"sourceURLs": [
"https://www.walmart.com/ip/Buxton-Men-s-Expedition-II-Huntington-Gear-Fold-Over-Canvas-Backpack-Tan/132557069",
"https://www.walmart.com/ip/Buxton-Men-s-Expedition-II-Huntington-Gear-Fold-Over-Canvas-Backpack-Gray-Camo/132557069",
"https://www.walmart.com/ip/Buxton-Men-s-Expedition-II-Huntington-Gear-Fold-Over-Canvas-Backpack-Tan/194246060"
]
},
{
"amountMin": 30.99,
"amountMax": 30.99,
"sourceURLs": [
"https://www.newegg.com/buxton-ex91423-laptop-bags-olive/p/03V-008V-000C9"
]
}
],
"id": "AWoQ5zqr0U_gzG0hacv-"
},
custom view is tied to your account
Please note that once created that your custom view is only tied to your account. If you have question about your view please reference the view ID and name with this API endpoint. https://api.datafiniti.co/v4/views?page=1&limit=10
You can also visit the API reference page here to test your new view or you can download the postman suite here.
Updated over 1 year ago