Inventory Report and High Order Complexity

Hello Community,

I’ve been searching for a way to grab the Inventory Report via this API.
The report in the Dashboard contains the fields “Sales Last 7 Days” and “Sales Last 30 Days”.
I haven’t found a matching model to request that specific report so I was planning to instead grab Order Data and aggregate on that. This way, in theory, I would be able to archieve the desired results. However requesting Orders with lineItems is fairly expensive with a complexity of 100 per Order. Obviously this is not feasible.

{
  orders(analyze:true){
    complexity
    data(first: 1){
      pageInfo{
        hasNextPage
        endCursor
      }
      edges{
        node{
          id
          order_number
          partner_order_id
          shop_name
          line_items {
            edges{
              node{
                id
                product_id
                sku
                quantity
                quantity_shipped
                
}}}}}}}}

Is there a better way to archieve what I’m trying here?
I’m trying to avoid storing Orders longterm in house just for this purpose.

Regards
Stefan

If I may add to that:
It would be impossible to grab new orders once the amount exceeds 50/hour.
This is not the case yet, but I’m sure in future this is fairly possible and other users might already be affected.

@sHelme we were not planning on exposing that report in api since its available in the webapp, but we will evaluate the effort of exposing in the public api and come back with an answer.

Hello @seba
Thank you for your reply.
I’d be very happy if you were able to provide that report via API.

I’ve also checked with the old REST API if this would be possible however haven’t found a way to export that. Am I correct here or have I missed something?

Regards
Stefan

that’s right, it is only available on the webapp.

I’d like to be able to get all the reports available on the webapp via the api as well. Automated reporting on time cycles would greatly improve our analytics. This will potentially save us a lot of time and money.

Thanks!

To add to the intial issue of the “high complexity”.
This high complexity of 100 per Order is caused by line_items. They’re by default queried with a limit of “100”.
In order to decrease complexity simply add a limit to the line_items query like this:

   {
      orders(analyze:true){
        complexity
        data(first: 1){
          pageInfo{
            hasNextPage
            endCursor
          }
          edges{
            node{
              id
              order_number
              partner_order_id
              shop_name
              line_items (first: 10) {
                pageInfo{
                  hasNextPage
                  endCursor
                }
                edges{
                  node{
                    id
                    product_id
                    sku
                    quantity
                    quantity_shipped
}}}}}}}}

In case you get more then one page of line_items iterate over the pages same as you would with multiple pages of orders.
This in theory would allow to generate a sales report by aggregating over the data queried here.

Regards
Stefan

1 Like