Looking for a solution to obtain inventory_changes

Hi Team,

we have a requirement to obtain inventory change log via graphql api.

I am experimenting few combination of queries to obtain inventory log using the “first” and “after” but it always returns a SKU from 2022 and none from recent changes

query {
  inventory_changes {
    request_id
    complexity
    data(first: 1, after: "2025-01-04T00:00:00") {
      edges {
        node {
          user_id
          account_id
          warehouse_id
          sku
          previous_on_hand
          change_in_on_hand
          reason
          cycle_counted
          location_id
          created_at
          location {
            id
            legacy_id
            account_id
            warehouse_id
            name
            zone
            pickable
            sellable
            is_cart
            temperature
            last_counted
            created_at
          }
        }
      }
    }
  }
}

response

{
    "data": {
        "inventory_changes": {
            "request_id": "XXXXXXXXX",
            "complexity": 2,
            "data": {
                "edges": [
                    {
                        "node": {
                            "sku": "SKUnumber",
                            "previous_on_hand": 0,
                            "change_in_on_hand": 2,
                            "reason": null,
                            "cycle_counted": false,
                            "location_id": "xxxxxxxxxxx=",
                            "created_at": "2022-09-30T17:56:38"
                        }
                    }
                ]
            }
        }
    },
    "extensions": {
        "throttling": {
            "estimated_complexity": 2,
            "cost": 2,
            "cost_detail": {
                "inventory_changes": {
                    "items_count": 1,
                    "cost": 1,
                    "total_cost": 2,
                    "fields": {}
                }
            },
            "user_quota": {
                "credits_remaining": 2000,
                "max_available": 2002,
                "increment_rate": 30
            }
        }
    }
}

Hi! The “after” in the data filter is for cursors, not dates. If you want to filter by dates, there are date_from and date_to available. Keep in mind that the criteria would go inside of parenthesis just after “inventory_changes” and not “data”. The API doc page on inventory_changes has more info.

1 Like

@jeremyw Many thanks. This information is very helpful!

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