I have a website custom built on node.js and I want to be able to get all of my products in a GET request. The shopify buy-button is not allowing me to have all of the products brought into the page at once (it has pagination), which is preventing me from properly filtering through all of the products (I have custom filters on the site).
Thus, based on a post that I read in shopify forums I'm looking to do something like the following:
<div class="wps-buy-button" id='[product-id]-[var-id]' data-id='[product-id]' data-var='[var-id]'></div>
This will allow me to filter through all of the different shopify products. However, the difficult part is now getting the product-id
and var-id
fields. One would think that simply going to Products => All Products => Export would be enough, but they don't list the product-id and var-id in that.
I've tried using the Shopify-Buy npm module, which looks like the following code, but am getting an ugly, unusable response:
So my question is, how can I get a response of all of my different Shopify products, either using an API, or whatever, without having to use PHP, or pay for a shopify plugin just to get product-ids and var-ids (I'm on Shopify lite plan since I'm just plugging it into my existing platform).
CODE:
import Client from 'shopify-buy';
const client = Client.buildClient({
domain: 'your-shop-name.myshopify.com',
storefrontAccessToken: 'your-storefront-access-token'
});
// Fetch all products in your shop
client.product.fetchAll().then((products) => {
// Do something with the products
console.log(products);
});
RESPONSE:
[ GraphModel {
id: [Getter],
handle: [Getter],
description: [Getter],
descriptionHtml: [Getter],
updatedAt: [Getter],
title: [Getter],
image: [Getter],
products: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: false,
hasPreviousPage: false,
variableValues: { first: 20, productsFirst: 20 } },
type: { name: 'CollectionConnection',
kind: 'OBJECT',
fieldBaseTypes: { edges: 'CollectionEdge', pageInfo: 'PageInfo' },
implementsNode: false } ]
[ GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: false,
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: { [Boolean: true] value: true },
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
GraphModel {
id: [Getter],
availableForSale: [Getter],
createdAt: [Getter],
updatedAt: [Getter],
descriptionHtml: [Getter],
description: [Getter],
handle: [Getter],
productType: [Getter],
title: [Getter],
vendor: [Getter],
publishedAt: [Getter],
onlineStoreUrl: [Getter],
options: [Getter],
images: [Getter],
variants: [Getter],
refetchQuery: [Getter],
type: [Getter],
nextPageQueryAndPath: [Function],
hasNextPage: true,
hasPreviousPage: { [Boolean: true] value: true },
variableValues: { first: 20, productsFirst: 20 } },
type: { name: 'ProductConnection',
kind: 'OBJECT',
fieldBaseTypes: { edges: 'ProductEdge', pageInfo: 'PageInfo' },
implementsNode: false } ]