Find complementary items for an order (frontend)
POST /v2/recommendations/orders/{order_id}/complementary_items
Returns the recommended complementary items for an order. For each item in an order, returns an array of complementary items that are available in the selected store. By default, an item can have up to five complementary items.
info
Use this endpoint with a user access token for frontend implementations. For backend implementations, see Find complementary items for an order (backend).
Security
Name | In | Description |
---|---|---|
Authorization | header | The Authorization header with the bearer token acquired during authentication. |
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
order_id | path | string | The ID of the order. |
Request
Field | Type | Required | Description |
---|---|---|---|
max_complementary_items | integer | The maximum number of suggested complementary items to be returned. Defaults to 5. |
Request examples
- cURL
- Java
- Python
- Go
curl --request POST \
--url 'https://connect.instacart.com/v2/recommendations/orders/{order_id}/complementary_items' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"max_complementary_items": 1
}'
HttpResponse<String> response = Unirest.post("https://connect.instacart.com/v2/recommendations/orders/{order_id}/complementary_items")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <token>")
.body("{\n \"max_complementary_items\": 1\n}")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
payload = "{\n \"max_complementary_items\": 1\n}"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("POST", "/v2/recommendations/orders/{order_id}/complementary_items", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://connect.instacart.com/v2/recommendations/orders/{order_id}/complementary_items"
payload := strings.NewReader("{\n \"max_complementary_items\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
Field | Type | Required | Description |
---|---|---|---|
complementary_items | Array(Item) | The suggested complementary items. |
Item Object
Field | Type | Required | Description |
---|---|---|---|
rrc | string | The item's retailer reference code (rrc). | |
upc | string | The item's universal product code (upc). |
Response examples
200 Success
200
Suggested complementary items returned
{
"complementary_items": [
{
"upc": "11111111111111"
}
]
}
4XX Errors
Error responses return either a single error or multiple errors.
HTTP Code | Cause | Error Message | Error Code | Error Meta |
---|---|---|---|---|
404 | Order not found | "Resource not found" | 4000 | Not applicable |