FROM CACHE - en_header

How can i get this ID number through API or other methods?

Solved
lifansun
New Member
6 0 0
Accepted Solution (1)

Accepted Solutions
Greg_Kujawa
Shopify Partner
1024 84 272
Replies 7 (7)
Greg_Kujawa
Shopify Partner
1024 84 272

This is an accepted solution.

lifansun
New Member
6 0 0

thx, but it's GraphQL API, where is the RESTful Publication api ? I can't found it.

Greg_Kujawa
Shopify Partner
1024 84 272

I can't find it either 🙂 Most likely this endpoint is only accessible using the GraphQL API. I had to resort to using it for a few queries that weren't possible using the REST API. Once you get used to the JSON request body format of these GraphQL queries it isn't that formidable. You can even test things out by trying out the real-time Shopify GraphQL explorer --> https://shopify.dev/tools/graphiql-admin-api.

lifansun
New Member
6 0 0
lifansun
New Member
6 0 0

hello, can you give me some example code to get this ID number through GraphQL API?

 
Greg_Kujawa
Shopify Partner
1024 84 272

Here's a sample that would retrieve the first 10 publication channels for the Shopify shop.

 

{
  publications (first: 10){
    edges {
      node {
        id
        name
      }
    }
  }
}
Greg_Kujawa
Shopify Partner
1024 84 272

And here is a sample, where I know the GID of a specific Shopify product. And use that to query various properties. The results will show the id and name of each published channel and the id and name of the channels where the product isn't published. You can determine the GID of a product by the REST API response for GET'ing a product. The field in the response is admin_graphql_api_id.

 {
    product(id: "gid://shopify/Product/4425923133492") {
      availablePublicationCount
      collections(first: 5) {
        edges {
          node {
            handle
          }
        }
      }
      createdAt
      defaultCursor
      description
      descriptionHtml
      featuredImage {
        id
      }
      feedback {
        details {
          messages {
            message
          }
        }
      }
      giftCardTemplateSuffix
      handle
      hasOnlyDefaultVariant
      hasOutOfStockVariants
      id
      images(first: 5) {
        edges {
          node {
            id
          }
        }
      }
      isGiftCard
      legacyResourceId
      metafield(key: "app_key", namespace: "affiliates") {
        description
      }
      metafields(first: 5) {
        edges {
          node {
            description
          }
        }
      }
      onlineStorePreviewUrl
      onlineStoreUrl
      options {
        name
      }
      priceRange {
        maxVariantPrice {
          amount
        }
        minVariantPrice {
          amount
        }
      }
      productType
      publicationCount
      publishedAt
      resourcePublications(first: 10) {
        edges {
          node {
            isPublished
            publication {
              id
              name
            }
          }
        }
      }
      seo {
        title
      }
      storefrontId
      tags
      templateSuffix
      title
      totalInventory
      totalVariants
      tracksInventory
      unpublishedPublications(first: 5) {
        edges {
          node {
            id
            name
          }
        }
      }
      updatedAt
      variants(first: 5) {
        edges {
          node {
            displayName
          }
        }
      }
      vendor
    }
  }