The Multiple Get API provides a simple and fast interface to retrieve Products by their product ids.
For example, the following query will retrieve products whose product_ids are 123ABC-S-Black and 123ABC-S-Blue
{
"product_ids": ["123ABC-S-Black", "123ABC-S-Blue"]
}
Miso will respond with the complete Products records in the same order as the given product_ids:
{
"message": "success",
"data": {
"products": [
{
"_found": true,
"product_id": "123ABC-S-Black",
"title": "Product ABC in Black",
...
},
{
"_found": true,
"product_id": "123ABC-S-Blue",
"title": "Product ABC in Blue",
...
}
]
}
}
You can use the _found field to determine whether a product is found in the Miso database or not.
When the given product_id is not found, the _found field in the corresponding Product record
will become false.
For example, the following query requests a product_id that does not exist in the Miso database:
{
"product_ids": ["Product_Not_Exists", "123ABC-S-Black"]
}
Miso will respond:
{
"message": "success",
"data": {
"products": [
{
"_found": false,
"product_id": "Product_Not_Exists"
},
{
"_found": true,
"product_id": "123ABC-S-Black",
"title": "Product ABC in Black",
...
}
]
}
}
Finally, like every Miso API, you can use fl to control what Product fields to return. By default, all the Product
fields will be returned, but the following query will return only title field of the product (in addition
to product_id)
{
"product_ids": ["123ABC-S-Black", "123ABC-S-Blue"],
"fl": ["title"]
}
Your secret API key is used to access every Miso API endpoint. You should secure this key and only use it on a backend server. Never leave this key in your client-side JavaScript code. If the private key is compromised, you can revoke it in Dojo and get a new one.
Specify your secret key in the api_key query parameter. For example:
POST /v1/users?api_key=039c501ac8dfcac91c6f05601cee876e1cc07e17List of product_ids to retrieve. Products will be returned in the same order as they are given in this list.
The engine you want to get results from. When you have more than one engine, you can use this parameter to specify the specific engine you want to get results from. If not specified, the default engine will be used.
The user who made the query and for whom Miso will personalize the results. For an anonymous visitor, use anonymous_id instead.
The anonymous visitor who made the query and for whom Miso will personalize the results. Either
user_id or anonymous_id needs to be specified for personalization to work.
The hash of user_id (or anonymous_id) encrypted by your Secret API Key.
user_hash is required to prevent unauthorized API access if you are
making API calls with a Publishable API Key.
You should generate the user_hash via HMAC scheme: you encrypt the desired user_id (or anonymous_id) with your Secret API Key on your backend server, and then let the front-end code send the generated user_hash to Miso APIs to verify the identity of the API caller.
As long as the Secret API Key is kept secret, the user_hash prevents a malicious attacker from making unauthorized API calls or impersonating any of your users.
Miso APIs accept the case-incentive "hex digest" of user hash, a sample Python 3 code to generate it on your backend server is as follow:
import hashlib
import hmac
YOUR_MISO_SECRET_API_KEY = "039c501ac8dfcac91"
key_bytes = YOUR_MISO_SECRET_API_KEY.encode()
user_id = "USER_123" # or anonymous_id
user_id_bytes = user_id.encode()
user_hash = hmac.new(
key_bytes,
user_id_bytes,
hashlib.sha256).hexdigest()
# user_hash is "7eb04da5e..."You can find more examples for other languages in this Github Gist
List of fields to retrieve. For example, the following request retrieves only the title field of each product
along with the product_id, which is always returned.
{"fl": ["title"]}You can also match field names by using * as a wildcard. For example, the query below retrieves the title
and any custom attributes under the attributes dictionary.
{"fl": ["title", "attributes.*"]}The following retrieves all the available fields (which is the default):
{"fl": ["*"]}For the lowest latency, use an empty array to retrieve just the product_id field.
{"fl": []}