Listing Products GraphQL
The products
GraphQL query allows you to pull product information of your choosing, from the KornitX platform, in JSON format.
Our GraphQL schema for products can be found here: https://developers-v2.custom-gateway.net/graphql/product.doc.html
a PHP based example showing how to consume the API: https://bitbucket.org/gateway3d/graphql-php-examples/src/master/examples/products.php
This API created by KornitX allows you to get product information from our Catalog module to enable it to be imported into other systems.
To utilise this you need to have an platform OAUTH user set up with access to product.customisable.view
and product.customisable.list
along with any relevant categories. If you do not have an OAUTH user you can request one by submitting a request to the support team. When you have this you will be provided with a Client ID and client secret that you can use to authenticate on the API endpoint.
An example authentication request is below where the 2 red portions would be where you add your own credentials from the steps above (note running this requires you to have curl and jq installed
TOKEN=`curl " https://oauth.kornitx.net/token" -d"client_id= **REDACTED**&client_secret= **REDACTED**&grant_type=client_credentials&scope=product.customisable.view products.customisable.list" -vv | jq .access_token -r
Once you have authenticated and have obtained a token you can run the API endpoint with filters.
An example curl for this endpoint is available here which would follow on from the authentication above
curl -H"Authorization: Bearer $TOKEN" -d'{"query":"query($page: Int!, $filter: Json!) { core { products(filter: $filter, page: $page, count: 100) { pages { pageCount, current }, items { id, name, snapshots { large } } } } }", "variables": { "filter": { "category_id": 12345 }, "page": 1 } }' "https://graphql.kornitx.net"
The query is a bit easier to read when multiline:
query($page: Int!, $filter: Json!) {
core {
products(filter: $filter, page: $page, count: 100) {
pages {
pageCount
current
},
items {
id
name
snapshots {
large
}
}
}
}
}
You can also add addition information into the request, anything in Product Manager can be gathered this way, see the additional below example adding more
query($page: Int!, $filter: Json!) {
core {
products(filter: $filter, page: $page, count: 250) {
pages {
pageCount
current
},
items {
id
productCode
retail_sku
name
snapshots {
large
}
ecommerce {
sales_description
sales_description_long
}
legacy_tier_prices {
items {
quantity
price
rrp
}
}
}
}
}