# How to get inventory based on lot number using graphql

**URL:** <https://community.shiphero.com/t/how-to-get-inventory-based-on-lot-number-using-graphql/3386>\
**Category:** GraphQL API\
**Created:** [May 8, 2025, 5:58am UTC](https://community.shiphero.com/t/how-to-get-inventory-based-on-lot-number-using-graphql/3386 "2025-05-08T05:58:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vraja](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@vraja](https://community.shiphero.com/u/vraja)\
**Post date:** [May 8, 2025, 5:58am UTC](https://community.shiphero.com/t/how-to-get-inventory-based-on-lot-number-using-graphql/3386/1 "2025-05-08T05:58:47Z")

</div>

Hello,

This is my query for import products from shiphero:  
query = “”"  
query {  
products {  
request\_id  
complexity  
data(first:100) {  
pageInfo {  
hasNextPage  
hasPreviousPage  
startCursor  
endCursor  
}  
edges {  
node {  
id  
legacy\_id  
account\_id  
name  
sku  
barcode  
country\_of\_manufacture  
dimensions {  
height  
width  
length  
weight  
}  
product\_note  
active  
warehouse\_products {  
warehouse\_id  
on\_hand  
}  
images {  
src  
}  
tags  
kit\_components {  
sku  
quantity  
}  
}  
cursor  
}  
}  
}  
}  
“”"  
From this I can get the actual on hand Quantity (Total in all the lots).

However,  
When I call this query for change in inventory:  
query = “”"  
query {  
inventory\_changes(date\_from: “%s” date\_to: “%s”) {  
request\_id  
complexity  
data(first:10){  
pageInfo {  
hasNextPage  
hasPreviousPage  
startCursor  
endCursor  
}  
edges {  
node {  
user\_id  
account\_id  
warehouse\_id  
sku  
previous\_on\_hand  
change\_in\_on\_hand  
reason  
cycle\_counted  
lot\_id  
lot\_name  
lot\_expiration  
location\_id  
created\_at  
location {  
id  
legacy\_id  
account\_id  
warehouse\_id  
name  
zone  
pickable  
sellable  
is\_cart  
temperature  
last\_counted  
created\_at  
}  
}  
}  
}  
}  
}  
“”" % (date\_from, date\_to)

I do not get the correct on hand quantity by lots.

What to do to get the correct on hand quantity by lots?

---

<div class="post-metadata">

**Author:** ![Nathan-Rhodes](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nathan-Rhodes](https://community.shiphero.com/u/Nathan-Rhodes)\
**Post date:** [May 8, 2025, 1:48pm UTC](https://community.shiphero.com/t/how-to-get-inventory-based-on-lot-number-using-graphql/3386/2 "2025-05-08T13:48:24Z")

</div>

Hi there!

Thanks for your submission. Could you share some more details on what your trying to achieve?

In order to find quantity of a sku by lots you should be able to make a call using warehouse\_products like:

{  
warehouse\_products {  
request\_id  
complexity  
data(first: 1) {  
pageInfo {  
hasNextPage  
hasPreviousPage  
startCursor  
endCursor  
}  
edges {  
node {  
id  
legacy\_id  
account\_id  
sku  
locations {  
edges {  
node{  
expiration\_lot {  
name  
id  
}  
quantity  
}  
}  
}  
}  
}  
}  
}  
}

Note that because lot information is highly nested you would need to reduce the number of results to less than 100. If you need a larger dataset pagination would be the key.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/2X/8/83f2a5ec5d7908b156cb6999baa4c753fadfa85d.svg) [@system](https://community.shiphero.com/u/system)\
**Post date:** [August 6, 2025, 1:48pm UTC](https://community.shiphero.com/t/how-to-get-inventory-based-on-lot-number-using-graphql/3386/3 "2025-08-06T13:48:41Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
