FROM CACHE - en_header

get vendors ids

Tarekrida1
New Member
2 0 0

how can i get all vendors with vendor id in store by shopify api and get vendor id in order items ?

Replies 4 (4)
Greg_Kujawa
Shopify Partner
1023 84 266

Using the GraphQL API, you can pull vendors like this. The example is just pulling the first 200 vendor names for the shop, but your query can be modified as needed.

 

 

query productVendors {
  shop {
    productVendors(first: 200) {
      edges {
        node
      }
    }
  }
}

 

 

  

Then here is an example where I am pulling the 10 most recent orders, pulling the first 5 line items of each order, and then listing the vendor name for each item sold. Again, you can modify the query as needed.

 

 

{
  orders(first: 10, reverse: true) {
    edges {
      node {
        id
        createdAt
        lineItems(first: 5) {
          edges {
            node {
              id
              title
              vendor
            }
          }
        }
      }
    }
  }
}

 

 

 

This should at least give you an idea about the general area. Hope this helps!

Tarekrida1
New Member
2 0 0

Now I am using REST api not GraphQL  Is this return vendors ids ?

 
Greg_Kujawa
Shopify Partner
1023 84 266

AFAIK there isn't a REST API endpoint to pull all vendors, just an API endpoint for pulling products. From which you could collect the assigned vendors. Using the GraphQL API isn't too bad once you get used to the mindset. Plus that's the eventual direction it seems Shopify might be headed to in terms of development roadmaps.

webxtor
New Member
2 0 0

How can you kindly modify these queries to get ALL the vendors? It seems to be not possible!