products

Version 2024-04-01

Overview

Returns multiple products from catalog system

ℹ️

Required scope(s)

View & Edit Catalog Data

Response

Return type ProductConnection

Arguments

ArgumentDescription
after (String)

Takes an optional cursor String for forward pagination along with first index.

The size should be greater than or equal to 0 and less than or equal to 65535.

first (Int)

Takes an optional non-negative integer for forward pagination along with after cursor.

The size should be greater than or equal to 0 and less than or equal to 20.

Examples


Query List Products With Page Size

Request

query products {
    products(first: 1) {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        edges {
            cursor
            node {
                id
                ... on Product {
                    id
                    externalId {
                        value
                    }
                    sku {
                        value
                    }
                    amazonSku {
                        marketplaceId
                        value
                    }
                    offerPrime
                    productDetailPageUrl
                    image {
                        displayReadyUrl
                        sourceUrl
                    }
                }
            }
        }
    }
}

Response

{
  "data": {
    "products": {
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": false,
        "startCursor": "catalogid#example-id-1",
        "endCursor": "catalogid#example-id-1"
      },
      "edges": [
        {
          "cursor": "catalogid#example-id-1",
          "node": {
            "id": "example-id-1",
            "externalId": {
              "value": "example-external-id-1"
            },
            "sku": {
              "value": "example-sku-1"
            },
            "amazonSku": {
              "marketplaceId": null,
              "value": "example-amazonSku-1"
            },
            "offerPrime": "true",
            "productDetailPageUrl": "https://example.com/products/id1",
            "image": {
              "displayReadyUrl": "https://example.com/product-image-display.jpeg",
              "sourceUrl": "https://example.com/product-image.jpeg"
            }
          }
        }
      ]
    }
  }
}

Query List Products Using After

Request

query products {
    products(after: "catalogid#example-id-2") {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        edges {
            cursor
            node {
                id
                ... on Product {
                    id
                    externalId {
                        value
                    }
                    sku {
                        value
                    }
                    amazonSku {
                        marketplaceId
                        value
                    }
                    offerPrime
                    productDetailPageUrl
                    image {
                        displayReadyUrl
                        sourceUrl
                    }
                }
            }
        }
    }
}

Response

{
  "data": {
    "products": {
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": true,
        "startCursor": "catalogid#example-id-2",
        "endCursor": "catalogid#example-id-3"
      },
      "edges": [
        {
          "cursor": "catalogid#example-id-2",
          "node": {
            "id": "example-id-2",
            "externalId": {
              "value": "example-external-id-2"
            },
            "sku": {
              "value": "example-sku-2"
            },
            "amazonSku": {
              "marketplaceId": null,
              "value": "example-amazonSku-2"
            },
            "offerPrime": true,
            "productDetailPageUrl": "https://example.com/products/id2",
            "image": {
              "displayReadyUrl": "https://example.com/product-image-display.jpeg",
              "sourceUrl": "https://example.com/product-image.jpeg"
            }
          }
        },
        {
          "cursor": "catalogid#example-id-3",
          "node": {
            "id": "example-id-3",
            "externalId": null,
            "sku": {
              "value": "example-sku-3"
            },
            "amazonSku": null,
            "offerPrime": false,
            "productDetailPageUrl": null,
            "image": null
          }
        }
      ]
    }
  }
}

Query List Products Without Conditions

Request

query products {
    products {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        edges {
            cursor
            node {
                id
                ... on Product {
                    id
                    externalId {
                        value
                    }
                    sku {
                        value
                    }
                    amazonSku {
                        marketplaceId
                        value
                    }
                    offerPrime
                    productDetailPageUrl
                    image {
                        displayReadyUrl
                        sourceUrl
                    }
                }
            }
        }
    }
}

Response

{
  "data": {
    "products": {
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": false,
        "startCursor": "catalogid#example-id-1",
        "endCursor": "catalogid#example-id-2"
      },
      "edges": [
        {
          "cursor": "catalogid#example-id-1",
          "node": {
            "id": "example-id-1",
            "externalId": {
              "value": "example-external-id-1"
            },
            "sku": {
              "value": "example-sku-1"
            },
            "amazonSku": {
              "marketplaceId": null,
              "value": "example-amazonSku-1"
            },
            "offerPrime": "true",
            "productDetailPageUrl": "https://example.com/products/id1",
            "image": {
              "displayReadyUrl": "https://example.com/product-image-display.jpeg",
              "sourceUrl": "https://example.com/product-image.jpeg"
            }
          }
        },
        {
          "cursor": "catalogid#example-id-2",
          "node": {
            "id": "example-id-2",
            "externalId": null,
            "sku": {
              "value": "example-sku-2"
            },
            "amazonSku": null,
            "offerPrime": null,
            "productDetailPageUrl": null,
            "image": null
          }
        }
      ]
    }
  }
}

Query List Products With Invalid Page Size

Request

query products {
    products(first: 21) {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        edges {
            cursor
            node {
                id
                ... on Product {
                    id
                    externalId {
                        value
                    }
                    sku {
                        value
                    }
                    amazonSku {
                        marketplaceId
                        value
                    }
                    offerPrime
                    productDetailPageUrl
                    image {
                        displayReadyUrl
                        sourceUrl
                    }
                }
            }
        }
    }
}

Response

{
  "errors": [
    {
      "message": "Input request is not valid, the following issues were encountered: [/products/first must be less than or equal to 20]",
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ],
      "path": [
        "products"
      ],
      "extensions": {
        "classification": {
          "type": "ValidationError",
          "code": "UnspecifiedError",
          "details": {},
          "errorType": "ValidationException",
          "errorCode": 400
        }
      }
    }
  ],
  "data": {
    "products": null
  }
}