Metafields are an experimental feature to Smart Wishlist REST API. The purpose of this API is to enable customization of the Wishlist based on certain metafield values.
However, this API allows you to fetch any metafield value from Shopify, (including those unrelated to our app).
This API is read only as of now. Only GET requests are supported. Below is the documentation.
REQUEST
There are 3 parameters to the passed along with request.
resource: It could be product.metafields or product.metafields.namespace.key.
parentid: Corresponding product ID
requesttime: The Unix timestamp in milliseconds. In Javascript, you can get this by Date.now() function. In server side scripts like PHP, there are functions to get this value.
For e.g.
GET /a/wishlist?type=api&resource=product.metafields.inventory.warehouse&parentid=4525968556085&requesttime=1642739825808
GET /a/wishlist?type=api&resource=product.metafields&parentid=4525968556085&requesttime=1642739825808
RESPONSE
The response would be in JSON, with the result parameter containing the value. If the resource is product.metafields.namespace.key, the result would simply contain the value. If resource is product.metafields, it would return all public metafields for that product. The result would contain another JSON with id,namespace,key,value and description.
{"response":{"type":"success","code":202,"shopifyresponsecode":0,"result":[{"id":20118706323509,"namespace":"inventory","key":"warehouse","value":25,"description":null},{"id":20118712352821,"namespace":"inventory","key":"warehouse2","value":26,"description":null}]}}
We strongly recommend that you cache the metafield values on the browser for at least 7 days, either as cookies or in local storage. This would reduce the amount of requests the app makes to the Shopify API on behalf of your store. Since Shopify imposes a rate limit on its API, a high traffic on the store can disrupt the process. Therefore a conservative usage is recommended.