Shipments Query by Order ID hits Credit Limit

Hi Team,

I wante to retrieve all the shipments by order ID but got an error due to credit limit. Our current max limit is 2002 but the required credits reached to 10101. Can you help me identify what is wrong with the query and what is the resolution or the proper way to get all the shipments of the order?

Payload Request:

query getShipmentsByOrderId {
  shipments(order_id: "T3JkZXI6NDk5Nzk3ODE3") {
    request_id
    complexity
    data {
      edges {
        node {
          order {
            id
            order_number
            fulfillment_status
          }
          id
          legacy_id
          line_items {
            edges {
              node {
                line_item {
                  id
                  product_name
                  quantity
                  quantity_shipped
                  sku
                  quantity_pending_fulfillment
                  quantity_allocated
                  fulfillment_status
                  product {
                    dimensions {
                      height
                      length
                      weight
                      width
                    }
                  }
                  warehouse
                  warehouse_id
                }
                shipping_label_id
              }
            }
          }
          shipping_labels {
            dimensions {
              height
              length
              weight
              width
            }
            box_name
            carrier
            package_number
            box_id
            id
            status
          }
          total_packages
          warehouse_id
          warehouse {
            id
            identifier
            legacy_id
          }
        }
      }
    }
  }
}

Payload Response:

{
  "data": null,
  "errors": [
    {
      "code": 30,
      "message": "There are not enough credits to perform the requested operation, which requires 10101 credits, The max allowed for your account is 2002 credits per operation. ",
      "operation": "shipments",
      "remaining_credits": 2002,
      "request_id": "66bb3648dce3378114037883",
      "required_credits": 10101,
      "time_remaining": "0"
    }
  ]
}

Looking forward for your response. Thank you.

Kind Regards,
Altair

Hi @Altair

The query needs a bit of optimization. Adding a First in the data and line_items arguments will filter it for what you need. Here is an article about it Getting Started – Developer Resources | ShipHero

query getShipmentsByOrderId {
  shipments(order_id: "T3JkZXI6NDk5Nzk3ODE3") {
    request_id
    complexity
    data(first: 10) {
      edges {
        node {
          order {
            id
            order_number
            fulfillment_status
          }
          id
          legacy_id
          line_items(first: 10) {
            edges {
              node {
                line_item {
                  id
                  product_name
                  quantity
                  quantity_shipped
                  sku
                  quantity_pending_fulfillment
                  quantity_allocated
                  fulfillment_status
                  product {
                    dimensions {
                      height
                      length
                      weight
                      width
                    }
                  }
                  warehouse
                  warehouse_id
                }
                shipping_label_id
              }
            }
          }
          shipping_labels {
            dimensions {
              height
              length
              weight
              width
            }
            box_name
            carrier
            package_number
            box_id
            id
            status
          }
          total_packages
          warehouse_id
          warehouse {
            id
            identifier
            legacy_id
          }
        }
      }
    }
  }
}

Have a nice day!