Shopify admin API, get product theme templates

Hello,
How can I get a list of available product template options via Shopify admin APIs (Rest or Graphql)?
In ProductInput fields (for product update/create mutation) we have a templateSuffix field to set, but I cannot find a way to get the list of all available product templates.
In Shopify admin, we have the block for it, that retrieves availableProductTemplateOptions array. I need the same but via admin API. Look at the screenshot:

2 Likes

Hello, did you find a solution for this?

Unfortunately, no

Someone just shared a solution with me. Apparently, you get them with the Assets API: https://shopify.dev/docs/api/admin-rest/2023-07/resources/asset#get-themes-theme-id-assets

But I don’t know if this will actually work. I guess the template prefix would be part of the key value?

1 Like

Hmm, it sounds like a possible solution, must try. Thank you!

I have the same issue. The asset API can get the assets of a theme. But there is no key filter. So I don’t think it can retrieve all product templates. Getting all theme assets and filter the files may work though

Did you found a solution?

Big thanks to @DavidT who pointed me at asset resource.

My solution:

import { authenticate } from "../shopify.server";
// shopify.server contains shopifyApp object initialization:
// import { shopifyApp } from "@shopify/shopify-app-remix/server";
// ...
// const shopify = shopifyApp(...);
// export const authenticate = shopify.authenticate;
// then exported authenticate variable is called below to get access to Rest API

const {admin, session} = await authenticate.admin(request);
const shopifyRestApi = admin.rest.resources;
const assets = await shopifyRestApi.Asset.all({ session: session, theme_id: 

`templateSuffixes` term comes from Page resouce: [https://shopify.dev/docs/api/admin-rest/2024-01/resources/page#get-pages](https://shopify.dev/docs/api/admin-rest/2024-01/resources/page#get-pages)

`template_suffix` holds value which bounds static page with specific template page.

At first I used Page resource to get all templates from theme, but one template page could be used by multiple static pages, so I searched for better solution. The 'better solution' is this Asset resource.