8SELECT - Integration Documentation
8SELECTService Status
  • 8.HX PLATFORM
  • Shop Integration
    • 8.SDK Web (JavaScript SDK)
    • Widgets
      • βž•Add more elements, like custom headline
      • πŸ‘»Hide recommendation area in case there is no content
      • πŸ”ŽAdding widgets after 8.SDK was loaded
      • πŸ—ΊοΈInternationalization
    • Shopping Cart
    • Checkout Tracking
    • Product Export
    • A/B Testing
    • Single Page Application
    • Tag Manager
    • Data Privacy / Cookies / GDPR
  • Widgets
    • 8.SIMILAR
    • 8.SET
    • 8.SET Custom
    • Touchpoints
      • Product Page
      • Cart Layer
      • Cart
      • Content Page
  • Product Export
    • Data Transfer
    • File Format
    • Base Data
      • Details and examples
    • Fashion Content Pool
      • Details and examples
    • Image Bot
  • Sandbox
    • Demo-Integration
    • Demo-Mode
  • API
    • Changelog
      • 2.0.0
      • 1.0.1
    • General
      • Introduction
      • Authentication
      • Pagination
      • Exceptions
      • GraphQL Schema
    • Examples
      • 8.SIMILAR
      • 8.SET
      • 8.SET Custom
      • Product Page - All Content
  • API Tracking
    • Changelog
    • General
      • Introduction
      • Authentication
      • Context
      • User Identification
      • Event Validation
    • Events
      • view
        • How to evaluate if view event can be sent
        • User views 8.SET content
      • interact
        • User clicks on a product within 8.SET content
        • User adds a product to their card from within 8.SET content
        • Example what is not a product interaction
      • order
Powered by GitBook
On this page
  • What we want to build
  • GraphQL query and response - id only
  • GraphQL query and response - full data

Was this helpful?

  1. API
  2. Examples

8.SIMILAR

Fetch similar products for a given product identifier.

PreviousExamplesNext8.SET

Last updated 10 months ago

Was this helpful?

What we want to build

We want to show a slider with up to 8 similar products on our product page.

GraphQL query and response - id only

To ensure that you show the most recent data in you shop you should only query the product ids and fetch the rest of the data you need for your UI from your own database.

query {
  product(id: "8S-DEMO-Polohemd-1") {
    similarProducts(first: 8) {
      edges {
        node {
          id
        }
      }
    }
  }
}
curl --request POST \
  --url https://api.8select.io/graphql \
  --header 'Content-Type: application/json' \
  --header 'x-api-id: db54750f-80fc-4818-9455-30ca233225dc' \
  --data '{"query":"query {\n  product(id: \"8S-DEMO-Polohemd-1\") {\n    similarProducts(first: 8) {\n      edges {\n        node {\n          id\n        }\n      }\n    }\n\t}\n}\n"}'
{
  "data": {
    "product": {
      "similarProducts": {
        "edges": [
          {
            "node": {
              "id": "8S-DEMO-Polohemd-10"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-9"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-7"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-8"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-2"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-3"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-4"
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-5"
            }
          }
        ]
      }
    }
  }
}

GraphQL query and response - full data

In case you can not make the extra roundtrip you can actually query all the data that is required to render a basic UI.

```groovy
query {
  product(id: "8S-DEMO-Polohemd-1") {
    similarProducts(first: 5) {
      edges {
        node {
          id
          brand
          images {
            edges {
              node {
                url
              }
            }
          }
          modelId
          name
          tags
          url          
          variants {
            edges {
              node {
                id
                variantId
                manufacturerSuggestedRetailPrice {
                  amount
                  currencyCode
                }
                price {
                  amount
                  currencyCode
                }
                
              }
            }
          }
        }
      }
    }
  }
}
```
curl --request POST \
  --url https://api.8select.io/graphql \
  --header 'Content-Type: application/json' \
  --header 'x-api-id: db54750f-80fc-4818-9455-30ca233225dc' \
  --data '{"query":"query {\n  product(id: \"8S-DEMO-Polohemd-1\") {\n    similarProducts(first: 5) {\n      edges {\n        node {\n          id\n          brand\n          images {\n            edges {\n              node {\n                url\n              }\n            }\n          }\n          modelId\n          name\n          tags\n          url          \n          variants {\n            edges {\n              node {\n                id\n                variantId\n                manufacturerSuggestedRetailPrice {\n                  amount\n                  currencyCode\n                }\n                price {\n                  amount\n                  currencyCode\n                }\n                \n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}"}'
{
  "data": {
    "product": {
      "similarProducts": {
        "edges": [
          {
            "node": {
              "id": "8S-DEMO-Polohemd-10",
              "brand": "8select Fashion",
              "images": {
                "edges": [
                  {
                    "node": {
                      "url": "https://wgt-prod.staging.8select.io/db54750f-80fc-4818-9455-30ca233225dc/demo/images/Polohemd-10.jpg"
                    }
                  }
                ]
              },
              "modelId": "8S-DEMO-Polohemd",
              "name": "Polohemd Alternative 10",
              "tags": [
                "sale",
                "sale_discount_4"
              ],
              "url": "https://www.8select.com/",
              "variants": {
                "edges": [
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-10-M",
                      "variantId": "M",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-9",
              "brand": "8select Fashion",
              "images": {
                "edges": [
                  {
                    "node": {
                      "url": "https://wgt-prod.staging.8select.io/db54750f-80fc-4818-9455-30ca233225dc/demo/images/Polohemd-9.jpg"
                    }
                  }
                ]
              },
              "modelId": "8S-DEMO-Polohemd",
              "name": "Polohemd Alternative 9",
              "tags": [
                "sale",
                "sale_discount_4"
              ],
              "url": "https://www.8select.com/",
              "variants": {
                "edges": [
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-9-M",
                      "variantId": "M",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-7",
              "brand": "8select Fashion",
              "images": {
                "edges": [
                  {
                    "node": {
                      "url": "https://wgt-prod.staging.8select.io/db54750f-80fc-4818-9455-30ca233225dc/demo/images/Polohemd-7.jpg"
                    }
                  }
                ]
              },
              "modelId": "8S-DEMO-Polohemd",
              "name": "Polohemd Alternative 7",
              "tags": [
                "sale",
                "sale_discount_4"
              ],
              "url": "https://www.8select.com/",
              "variants": {
                "edges": [
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-7-M",
                      "variantId": "M",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-8",
              "brand": "8select Fashion",
              "images": {
                "edges": [
                  {
                    "node": {
                      "url": "https://wgt-prod.staging.8select.io/db54750f-80fc-4818-9455-30ca233225dc/demo/images/Polohemd-8.jpg"
                    }
                  }
                ]
              },
              "modelId": "8S-DEMO-Polohemd",
              "name": "Polohemd Alternative 8",
              "tags": [
                "sale",
                "sale_discount_4"
              ],
              "url": "https://www.8select.com/",
              "variants": {
                "edges": [
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-8-M",
                      "variantId": "M",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "node": {
              "id": "8S-DEMO-Polohemd-2",
              "brand": "8select Fashion",
              "images": {
                "edges": [
                  {
                    "node": {
                      "url": "https://wgt-prod.staging.8select.io/db54750f-80fc-4818-9455-30ca233225dc/demo/images/Polohemd.png"
                    }
                  }
                ]
              },
              "modelId": "8S-DEMO-Polohemd",
              "name": "Polohemd Alternative 2",
              "tags": [
                "sale",
                "sale_discount_4"
              ],
              "url": "https://www.8select.com/",
              "variants": {
                "edges": [
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-2-M",
                      "variantId": "M",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  },
                  {
                    "node": {
                      "id": "8S-DEMO-Polohemd-2-L",
                      "variantId": "L",
                      "manufacturerSuggestedRetailPrice": {
                        "amount": "155.55",
                        "currencyCode": "EUR"
                      },
                      "price": {
                        "amount": "150.00",
                        "currencyCode": "EUR"
                      }
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}