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 ?

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

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!

0 Likes
Tarekrida1
New Member
2 0 0

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

 
0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

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.

0 Likes